Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Shells: User's Guide: HP 9000 Computers > Chapter 10 Preparing to Use the Shell

C Shell Startup

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

Depending on whether it is your default login shell, C Shell looks for one or all three of the following files and executes them as indicated in the order indicated, if they exist:

/etc/csh.login

If C Shell is your login shell and this file exists, it is executed.

.cshrc

If this file exists in your home (login) directory, it is executed every time C Shell starts, whether at login or when C Shell is spawned from another shell.

.login

If C Shell is your login shell and this file exists in your home directory, it is executed.

While none of these files is required, if present, they provide a convenient means for customizing the shell environment to fit your needs.

Setting Environment and Shell Variables

Two kinds of variables can be set in the .cshrc and .login files:

Environment variables

These variables are global (used by the login shell process and any processes spawned by the shell process). They are usually represented by uppercase letters.

Shell variables

Shell variables are local (used by the login shell process only) and are not inherited by spawned processes. They are usually represented by lowercase letters.

Environment variables are usually defined by using the setenv command, while shell variables are typically defined by the set command. However, three of the most commonly used environment variables - USER, TERM, and PATH - are automatically imported to and exported from three corresponding variables - user, term, and path. Thus, if you execute:

set path=(/bin/posix /bin /usr/bin)

the value of the environment variable PATH also becomes /bin/posix:/bin:/usr/bin (note the difference in syntax between the two variables).

The commands set and setenv can be executed interactively from a terminal, or they can be placed in the .cshrc or .login files.

The .cshrc Shell Script File

Whenever a C Shell starts during your session, it searches for the file .cshrc in your home directory and executes it if it exists. The information in this file is used to set variables and operating parameters that are local to the shell process.

Since every C Shell created executes this file, it is customary to use it for setting shell variables by including set commands in the file. If the .cshrc file does not exist in your home directory, HP-UX spawns C Shell using default values for needed variables.

To verify your current shell environment, execute set. A listing similar to the following is printed on the display:

[25] % set
argv ()
autologout 15
cwd /users/login_name
history 15
home /users/login_name
ignoreeof ignoreeof is set for this example
noclobber
prompt [!] %
shell /bin/csh
status 0
term hp2622
path (/bin/posix /bin /usr/bin /usr/local/bin /etc/users/login_name . )
[26] % _

Some of the commands commonly used in the .cshrc file and their meanings are shown in Table 10-1 “.cshrc File Commands”.

Table 10-1 .cshrc File Commands

Command

Meaning

set ignoreeof

Traps CTRL-D's to avoid accidental system log off. Use the logout or exit command.

set prompt = "[\!] %"

This command causes your C Shell prompt to be the current event number in square brackets followed by a percent sign. This is very helpful when using the command history buffer.

set history=15

Sequentially keeps a buffer of your last (15 in this case) events.

set savehist=15

This command saves the last (15 in this case) events when you log off your system. When you log back onto your system, the event history is restored.

set noclobber

This command stops C Shell from overwriting and destroying the information in an existing file.

 

You can suppress execution of the .cshrc file by using the -f option in the csh command as follows:

csh -f

The .login Shell Script File

When you activate C Shell by logging onto the system, C Shell looks for the shell script file .login in your home directory and executes it if it exists. This shell script file contains global commands, variables, and parameters that you want executed or set up automatically at the beginning of your session. Some of the commonly used commands you might want to include in this file and their meanings are shown below. The term login_name refers to your login name.

setenv TERM hp2622

Sets the system variable TERM to recognize the HP 2622 as your terminal.

setenv TZ MST7MDT

This command sets the time zone variable. The example specifies U.S. Mountain Standard Time/Mountain Daylight Savings Time Zone.

setenv PATH /bin/posix:/bin:/usr/bin:/usr/local/bin:/etc:/users/login_name:.

This command sets the search pattern the system uses for finding commands.

set mail=/usr/mail/login_name

Required to receive mail for HP-UX.

alias h history

Make the character h an alias for your command history file.

alias bye logout

For some, bye is easier to remember than logout as a session termination order.

news | more

Pipe the news through more.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-1991 Hewlett-Packard Development Company, L.P.