Environment variables

You can use environment variables to specify necessary system information.

Setting environment variables

Different commands are used to set the environment variables depending on whether you are using the z/OS® UNIX System Services shell (sh), which is based on the Korn Shell and is upward-compatible with the Bourne shell, or tcsh shell, which is upward-compatible with the C shell. To determine the current shell, use the echo command, which is echo $SHELL.

The z/OS UNIX System Services shell path is /bin/sh. The tcsh shell path is /bin/tcsh.

For more information about the NLSPATH and LANG environment variables, see z/OS XL C/C++ Programming Guide and z/OS UNIX System Services Command Reference.

Setting environment variables in z/OS shell

The following statements show how you can set environment variables in the z/OS shell:

LANG=En_US
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
PATH=/bin:/usr/lpp/cbclib/xlc/bin${PATH:+:${PATH}}
export LANG NLSPATH PATH

To set the variables so that all users have access to them, add the commands to the file /etc/profile. To set them for a specific user only, add the commands to the .profile file in the user's home directory. The environment variables are set each time the user logs in.

Setting environment variables in tcsh shell

The following statements show how you can set environment variables in the tcsh shell:

setenv LANG En_US
setenv NLSPATH /usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
setenv PATH /bin:/usr/lpp/cbclib/xlc/bin${PATH:+:${PATH}}

To set the variables so that all users have access to them, add the commands to the file /etc/csh.cshrc. To set them for a specific user only, add the commands to the .tcshrc file in the user's home directory. The environment variables are set each time the user logs in.

Setting environment variables for the message file

Before using the compiler, you must install the message catalogs and set the environment variables:

LANG
Specifies the national language for message and help files.
NLSPATH
Specifies the path name of the message and help files.
XL_CONFIG
Specifies the name of an alternative configuration file (.cfg) for the xlc utility. Note: For the syntax of the configuration file, see the description for the -F flag option in Flag options syntax.

The LANG environment variable can be set to any of the locales provided on the system. See the description of locales in z/OS XL C/C++ Programming Guide for more information.

The national language code for United States English may be En_US or C. If the Japanese message catalog has been installed on your system, you can substitute Ja_JP for En_US.

To determine the current setting of the national language on your system, see the output from both of the following echo commands:
  • echo $LANG
  • echo $NLSPATH

The LANG and NLSPATH environment variables are initialized when the operating system is installed, and may differ from the ones you want to use.