• Aucun résultat trouvé

Environment Variables

Environment variables define various characteristics of the environment in which your shell runs. Environment variables consist of a name and a value (NAME=value). Table 4-2 lists the environment variables used by the Korn, Bourne, and C shells. The assigned values of environment variables are used by your shell and passed to each process created during a session. For example, if you type the cd command without any options, it returns you to the directory contained in the HOME environment variable.

To see a list of all environment variables and their values defined in your shell environment, use the env command (see env(l) in the HP-UX Reference).

Note VUE reads different customization files to set environment variables than the standard HP- UX login scripts. Refer to the HP Visual User Environment (VUE) System Administration Manual for information on setting environment variables in VUE.

Login 4-13

4

4

Table 4-2. Shell Environment Variables

Variable Description Default Value

LOGNAME Contains the user's username. Set by login. from / ete/passwd HOME Defines the user's home directory. Set by from / ete/passwd

login.

PATH Lists the directories the system searches to find :/bin:/usr/bin executable commands. Set by login.

SHELL Contains the default shell. Set by login from /bin/sh command field of /ete/passwd. If there is no

password field, the default is used.

TERM Specifies the kind of terminal the user is logged hp in on. Set by the local login script.

TZ Provides the current time zone and difference MST7MDT from Greenwich Mean Time. Set to Mountain

Standard Time by your shell's default login script (the system administrator should change the value if you are in another time zone). TZ must be set identically in five different places:

/ete/re, /ete/esh.login, /ete/profile, /ete/powerfail, and (Series 300/400/700 only) / ete/mkrs.

MAIL Determines where the system looks for mail. /usr/rnail/$LOGNAME Set by login, based on the username (for

example, /usr/rnail/terry).

For details on setting and using environment variables, see Using HP- UX. The remainder of this section discusses two important environment variables: PATH and TERM.

4-14 Login

The Command Search Path (PATH)

When you type a command, HP -UX searches all the directories specified by the PATH variable until it finds the command. If the command is not in a directory specified in PATH, the system displays:

command_name: Command not found.

If you or users of the system use commands in a particular directory frequently, you may want to change PATH to include this directory.

PATH Variable Format

The PATH variable contains a list of directories to search, separated by colons.

There should be no spaces surrounding the colons. For example, suppose you use the echo command to determine the value of PATH, as follows:

$ echo $PATH

Ibin:/usr/bin

This means that when you type a command, the shell first searches for the command in the Ibin directory, then in the lusr Ibin directory.

Commonly Used PATH Directories

Table 4-3 shows the path names of the most frequently used directories. You might want to add some (or all) of these directories to PATH.

Table 4-3. Possible Directories to Include in PATH

Directory What It Contains

/bin Frequently used HP-UX commands.

jete Commands the system administrator uses.

/usr/bin Additional HP- UX commands.

/usr/eontrib/bin Contributed programs not supported by Hewlett-Packard.

/usr/loeal/bin Programs and commands written locally (at your location).

/usr/bin/X11 XII programs.

$HOME/bin A directory you might create for your shell scripts and programs.

Commands and programs stored in your current directory. If . IS

in your PATH, it should be the last entry.

Login 4-15 4

4

Remember that directories in PATH are searched in the order in which they appear (left to right). In general, put the most frequently used directories first in the path-unless two commands in the search path have the same name (for example, /bin/rm and $HOME/bin/rm). In this example, if you want the shell to find your version of rm first, put $HOME/bin/rm before /bin/rm in PATH.

Specification of Terminal Characteristics (TERM)

To communicate effectively with your terminal, HP- UX must know the type of terminal or graphics display you're using. The TERM environment variable, tset command, and stty command serve this purpose.

The default local login script prompts you to enter your terminal type as follows:

TERM

=

(hp)

Pressing (Return ], sets the TERM environment variable to hp, the default value (this value works with Hewlett-Packard terminals, but it may not let you take full advantage of your terminal or graphics display features). Entering a different value, sets the TERM environment variable to that value.

Selecting a Value for the TERM Variable

HP- UX supports many terminal types. The /usr/lib/terminfo database tells HP- UX how to communicate with each terminal type. When you assign a value to TERM, the value must equal a value in the terminfo database (see terminfo(4) in the HP-UX Reference).

To illustrate, the files listed under usr/lib/terminfo/2 show all acceptable TERM values that begin with 2 (this is only a partial listing):

$ Is /usr/lib/terminfo/2

2382 2397a 2621a 2623p 2626-x40 2640a

2392 2500 2621k45 2624 2626A 2640b

2392A 2621 2621nl 2624a 2626P 2644

2392a 2621-48 2621nt 2624p 2626a 2645

2393 2621-ba 2621p 2625 2626p 2647

2393A 2621-fl 2621wl 2626 2627 2647F

4-16 Login

Table 4-4 outlines the most common terminal and graphics display settings for Hewlett-Packard equipment. When more than one choice is listed, all choices are equivalent.

Note If you are using the HP Visual User Environment (VUE), HP recommends that you keep TERM set to hp. VUE has its own display requirements and thus looks in its own customization files for environment variables. Refer to the HP Visual User Environment System Administration Manual for information.

Table 4-4. Settings for the TERM Environment Variable If You Are Using a ... Set TERM to ...

terminal the terminal's model number (for

example, 2622, hp2622, 262x, 2392)

Vectra 2392

medium resolution graphics display 3001 or hp3001 (512x600 pixels)

high resolution graphics display 300h or hp300h (1024x768 pixels)

HP 98550 display station 98550,hp98550,98550a,orhp98550a (1280x1024 pixels)

HP 98720 or HP 98721 display station The graphics interface card number (1280x1024 pixels) (for example, 98720, hp98720,

98731, hp98736a)

Most users have a high-resolution terminal. The first setting you might try is hp300h. If that doesn't work, try the number of your graphics interface card (such as 987xx). You can look in /usr/lib/terminfo/9 for all the interface cards beginning with number 9, or /usr/lib/terminfo/h for all interface cards beginning with hp to find your exact number.

Setting TER M with the tset Command

Login 4-17

4

4

The tset command is a flexible command that sets the value of TERM and initializes your terminal characteristics. If you always log in using the same terminal type, you could change your local login script to eliminate the TERM prompt. In the local script, this command displays the TERM prompt:

eval ' tset -s -Q -m ':?hp' ,

To customize the above command, replace ?hp with the value of TERM. For example, the following command initializes your terminal as a high-resolution graphics display (300h), but the TERM prompt itself does not display:

eval ' tset -s -Q -m ':300h' ,

If you use more than one type of terminal (such as one at work and one at home), you could modify your tset command to include multiple terminal types. For an example, see "Sample C Shell .login Script".

Using stty to Modify and Display Terminal Characteristics

The stty command can be used to change various terminal characteristics, such as baud rate, erase and kill characters, etc. For example, the following stty command resets the erase and kill characters to # and @, respectively (the defaults during login):

$ stty erase # kill @

To change them back to the (Backspace) (( CTRLlEJ) and (CTRLXQ) keys, respectively, use:

$ stty erase ~H kill ~U

It also displays terminal settings if invoked with the -a option; for example:

$ stty -a

speed 9600 baud; line

=

0; susp

=

-@; dsusp

=

-@

intr

=

-C; quit

= -\;

erase

=

-H; kill

=

-U; eOI

=

-D; swteh

=

-@j eol

=

-@

-parenb -parodd es8 -estopb hupel eread eloeal -loblk -erts

-ignbrk brkint ignpar -parmrk -inpek -istrip -inler -igner iernl -iuele ixon ixany iXOII ienqak

isig ieanon -xease eeho eehoe eehok -eehonl -noIlsh

opost -oleue onler -oernl -onoer -onlret -oIill -oIdel -tostop

For details on the use and output of stty, see stty(l) in the HP-UX Reference.

4-18 Login

Specifying the Working Environment