Environment

Unix, DOS, Windows, O/S2... all operating systems start you off at a "shell." A shell is a command interpreter. It takes your keyboard entries and hands them to the computer in a way it can understand and act upon. When you are positioned at a shell prompt (DOS=C:\, Unix=$ or # or %, Windows=GUI Desktop interface) you are sitting in a special environment. There are two very important aspects of this environment:

The environment uses variables to control your operation.

You can change these variables to customize your environment to taste.

 

Environment Variables

 

This section contains

Setting Environment Variables (DOS)

Setting Environment Variables (UNIX/LINUX/XENIX)

Exporting Variables

Unsetting Environment Variables

Listing Environment Variables

 

·    DOS/WINDOWS

Setting Environment Variables

This is an easy matter under DOS. You use the "set" command. The syntax is:

       SET VARIABLENAME=VALUE

Example:

       SET MINE=C:\WORDPERFECT\WPDOCS\MYFILES

Once a variable is set in DOS, you use it by obtaining its contents with a % sign directly in front of it and directly after it. For example, if you set a variable in the above manner, you could use it like this:

       cd %MINE%

This tells the "cd" command (change directory) to change you to the long directory name contained in the variable MINE. A good shortcut. It is the very same thing as typing:

       cd C:\WORDPERFECT\WPDOCS\MYFILES

Unsetting Environment Variables

To unset a variable in DOS, use the syntax:

       set variablename=

By setting it equal to nothing, it goes away.

Listing Environment Variables

To list the envrionment variables in your environment (and their values) use the "set" command by itself. When you type "set" you might see a lising like this:

 

       BLASTER=A220 15 D1 H5 P330 T6 E620
       JAVA_HOME=C:\cafe\JAVA
       MINE=C:\WORDPERFECT\WPDOCS\MYFILES
       PATH=C:\cafe\JAVA;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\FP
       PFDSK=C
       TEMP=C:\TEMP

To see the contents of just one environment variable, use the "echo" command, as in:

       echo %MINE%

You will see:

       C:\WORDPERFECT\WPDOCS\MYFILES

·    UNIX / LINUX / XENIX

Setting Environment Variables

Under Unix, setting variables is even easier than under DOS. You do not even need the "set" command. The syntax is just:

       variablename=value

Example:

       mine=/usr/tracy/wp/myfiles

Exporting Variables

Once a variable is set in Unix, it is only useful to your current shell. That is to say, if you call up another program like filePro or WordPerfect, these variables are completely lost... they are simply not seen in that called environment. This is why you must always "export" any variable that you set under Unix. The syntax is very simple:

       export variablename

So, you can consider that setting any environment variable under Unix is a two-step process. First set it, then export it. You only have to export a variable one time. After that you can change its value as many times as you like, it will remain exported and always send out the right value to programs that you call. The whole syntax is as follows:

       variablename=value
       export variablename

Example:

       mine=/usr/tracy/wp/myfiles
       export mine

To obtain a variable's contents just place a $ directly in front of it. For example, if you set a variable in the above manner, you could use it like this:

       cd $mine

This tells the "cd" command (change directory is the same command in both Unix and DOS) to change you to the long directory name contained in the variable mine. Again, it is the very same thing as typing

       cd /usr/tracy/wp/myfiles

Unsetting Environment Variables

To unset an environment variable in Unix, use the "unset" command, as in:

       unset variablename

This will make it go away.

You can also set the variable equal to nothing as in:

;        e'#=""

But this will not clear it from the environment, just set it equal to nothing.

 

Listing Environment Variables

To list the envrionment variables in your environment (and their values) use the "set" command by itself. When you type "set" you might see a lising like this:

       PATH=/bin:usr/bin:/usr/$HOME/bin:/u/appl/fp
       PFTMP=/usr/tmp
       PS1=$
       TZ=EST5EDT

If you want to see which of these variables is exported, use the export command by itself, as in:

;        %äYou might see something like:

       export ABE=ASCII
       export PATH
       export PFTMP
       export PS1
       export TZ