3.3 Predefined Environment Variables

   

3.3 Predefined Environment Variables

There are some standard variables that many HP-UX commands use. These are called predefined because their names are standard. Here are some of these variables and their use by different commands.

  • PATH is the most commonly used environment variable. It contains the command search path or name of directories where your shell searches for a command when you issue it. Usually it is set up through the system startup file ( /etc/profile ) and can be modified by a user to add personal directories through the user startup file ( .profile ). Each directory in the PATH variable is separated by a colon .

  • HOME is automatically set when a user logs into HP-UX. It contains the path of the user's home directory. To refer to the .profile file in your home directory, you can use $HOME/.profile as the complete path to the file. Please note that there is another way to refer to your home directory in HP-UX, and that is the ~/ combination.

  • PWD shows the current directory. It is also set automatically whenever you use the cd command. It always has the value of the current directory.

  • SHELL shows the absolute path of your login shell. It is automatically set at the login time.

  • TERM contains the name or type of your terminal. It is usually set through the /etc/profile shell startup file using the tset or ttytype command.

  • PS1 contains the primary command prompt string. This string is displayed in your shell prompt. If $ is displayed as your command prompt, the value of PS1 is a $ symbol.

  • PS2 contains the secondary command prompt string. That is, if you issue a command that is incomplete, you will see a prompt by the shell with a value of PS2.

  • MANPATH contains the list of directories where the man command looks for manual pages. A colon separates each directory in the list.

  • TZ contains the local time zone that was set at the time of HP-UX installation. Commands such as date read this variable.

  • EDITOR contains the name of the editor you want to use for command line editing or for typing mail messages. You can set this variable in your shell startup file with your favorite editor.

  • HISTFILE contains the name of the history file where your command history is kept. All of the commands you use go to the history file.

  • HISTSIZE variable shows how many commands are kept in the history file.

Study Break

Predefined Environment Variables

Knowledge of shell variables is very helpful in understanding the behavior of some commands. Use the command:

 echo "Incomplete command test 

You will see a " > " symbol in the next line. You get back neither the command prompt nor any other display. You may be wondering what happened to the command. Actually, you issued an incomplete command, missing the closing double quotes. The symbol " > " is the value of the PS2 environment variable that is displayed whenever you use an incomplete command. Just complete the remaining part of the command and press the graphics/enter.gif key at this prompt.

Change this variable so that it gives a more meaningful message, such as "Incomplete command>" and again use the same command to check if it works. Using the set command, see which variables are set on your system. To find out more about an environment variable, get help with the man sh-posix command.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net