GETENV

The GETENV function returns the equivalence string for Name from the environment of the IDL process. If Name does not exist in the environment, a null string is returned.

Calling Sequence

Result = GETENV( Name )

Arguments

Name

The scalar string for which an equivalence string from the environment is desired.

Environment Variables Under VMS

VMS does not directly support the concept of environment variables. Instead, it is emulated (by using the standard C getenv() function) as described below, enabling you to use GETENV portably between Unix and VMS:

Example

To print the name of the current Unix shell, enter the command:

PRINT, 'The current shell is: ', GETENV('SHELL')

See Also

GET_SYMBOL (VMS Only) , SETENV (Unix and Windows Only) , TRNLOG

The Unix E nvironment

Every Unix process has an "environment." The environment consists of "environment variables," each of which has a string value associated with it. Some environment variables always exist, such as PATH that tells the shell where to look for programs or TERM that specifies the kind of terminal being used. Others can be added by the user, usually from an interactive shell and often from the .login file that is executed when you log in.

When a process is created, it is given a copy of the environment from its parent process. IDL is no exception to this; when started, it inherits a copy of its parent's environment. The parent process to IDL is usually the interactive shell from which it was started. In turn, any child process created by IDL (such as those from the SPAWN procedure) inherits a copy of IDL's current environment.

IDL provides two routines for manipulating the environment:

GETENV

The GETENV function returns the equivalence string from the environment of the IDL process. It has the form:

GETENV(; Name )

where Name is the name of the environment variable for which the translation is desired. If Name does not exist in the environment, a null string is returned. For example, to determine the type of terminal being used, you can enter the IDL statement:

PRINT, 'The terminal type is: ', GETENV('TERM')

Executing this statement on a Sun workstation give the following result:

The terminal type is: sun

SETENV

The SETENV function adds a new environment variable or changes the value of an existing environment variable in the IDL process. It has the form:

SETENV, ; Environment_Expression

where Environment_Expression is a scalar string containing an environment expression to be added to the environment.

For example, you can change the shell used by SPAWN by changing the value of the SHELL environment variable. An IDL statement to change to using the Bourne shell /bin/sh would be:

SETENV, 'shell=/bin/sh'