Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ env(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh(1)

set(1)

exec(1)

profile(4)

environ(5)

env(1)                                                               env(1)

NAME
     env - set environment for command execution

SYNOPSIS
     env [-i] [--] [name=value ...] [command [arg ...]]

DESCRIPTION
     The env command can be used to display current environment variables
     and their values or to set them for the execution of a specific com-
     mand. env inspects the current environment, modifies it according to
     the assignment in name=value, and then executes the command in the
     modified environment. The existing specifications for name and value
     are overwritten by the new ones, and the new arguments are merged into
     the inherited environment before the command is executed. The valid
     environment for the execution of command thus consists of the new
     specifications together with any unmodified environment variables.

     If no command is specified, env prints the resulting environment.

OPTIONS
     -i      The original environment is ignored; command is then executed
             with exactly the environment specified by the arguments.

             The -i option corresponds to the old - option, which will con-
             tinue to be supported.

     --      End of the list of options if the first argument begins with
             -.

     name=value
             name specifies the name of a variable that is to be valid for
             command.

             value is the value of name which is to apply to command.

     command Name of the command or shell script which you would like to
             have executed in the defined environment.

     arg     Argument, e.g. positional parameters or user-defined variables
             which can be passed to command.

EXIT STATUS
     0       env executed successfully

     1-125   Error

     126     The specified command exists, but cannot be invoked.

     127     The specified command cannot be found.






Page 1                       Reliant UNIX 5.44                Printed 11/98

env(1)                                                               env(1)

LOCALE
     The LCMESSAGES environment variable governs the language in which
     message texts are displayed. If LCMESSAGES is undefined or is defined
     as the null string, it defaults to the value of LANG. If LANG is like-
     wise undefined or null, the system acts as if it were not internation-
     alized.

     The LCALL environment variable governs the entire locale. LCALL
     takes precedence over all the other environment variables which affect
     internationalization.

EXAMPLES
   Example 1

     Output the current values of environment variables:

     $ env
     DRU01=-ws=G01
     HOME=/home/sysiphus
     LANG=EnUS.ASCII
     LOGNAME=sysiphus
     MAIL=/var/mail/sysiphus
     PATH=::/usr/bin:/usr/sbin:/opt/bin:
     PS1=$
     SHELL=/sbin/sh
     TERM=97801
     TERMCAP=/etc/termcap
     TTY=/dev/004
     TZ=MET-1MDT
     USER=sysiphus

   Example 2

     Output the modified values of environment variables:

     $ env PATH=$HOME/proc
     DRU01=-ws=G01
     HOME=/home/sysiphus
     LANG=EnUS.ASCII
     LOGNAME=sysiphus
     MAIL=/var/mail/sysiphus
     PATH=/home/sysiphus/proc
     PS1=$
     SHELL=/sbin/sh
     TERM=97801
     TERMCAP=/etc/termcap
     TTY=/dev/004
     TZ=MET-1MDT
     USER=sysiphus

     The PATH environment variable has been modified.



Page 2                       Reliant UNIX 5.44                Printed 11/98

env(1)                                                               env(1)

   Example 3

     Output modified values of environment variables using the - option:

     $ env - PATH=$HOME/proc
     PATH=/home/sysiphus/proc

     The original environment is ignored.

   Example 4

     Invocation of the file ardor, located in some/sisyphus/SAYINGS, i.e.
     in a subdirectory of the HOME directory.

     Contents of file ardor:

     echo "$1 $2 $3 $4 $2 $3 $1 love $4!"

     Now call ardor from any location in your file tree with the arguments
     I know that you:

     $ env PATH=$HOME/SAYINGS ardor I know that you
     I know that you know that I love you!

     With the new definition of the PATH variable, you effectively define
     the location where the entered command is to be sought (the file ardor
     in our case), i.e. in a subdirectory of the HOME directory, which you
     specify with the value of the variable HOME ($HOME).

     The character strings I, know, that, and you are passed as arguments
     to the positional parameters $1, $2, $3 and $4.

     The contents of ardor are correctly executed here because echo is a
     built-in command of the sh shell. Due to the change in the PATH vari-
     able, all Reliant UNIX commands in /usr/bin, /usr/sbin or /opt/bin can
     no longer be found. To enable the execution of Reliant UNIX commands
     again, the PATH variable must be modified as shown in the example
     below:

   Example 5

     Call the file delcopy, which is located in the directory
     /home/sisyphus/proc. This file contains a script that compares two
     files and deletes one of them if both files are identical.

     Contents of the file delcopy:

     if cmp -s $1 $2
     then
     rm $2
     fi



Page 3                       Reliant UNIX 5.44                Printed 11/98

env(1)                                                               env(1)

     Call the delcopy file from any location in your file tree with the
     arguments file1 and file2:

     $ env PATH=$PATH:$HOME/proc delcopy file1 file2

     In this case, the new path is appended to the original one. This
     ensures that the delcopy script can be executed along with all Reliant
     UNIX commands contained in it. If only the path for delcopy were
     specified, the following error message would be issued.

     /home/sisyphus/proc/delcopy: cmp: not found

SEE ALSO
     sh(1), set(1), exec(1), profile(4), environ(5).








































Page 4                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026