Develop Environments
Each environment can be described with Tcl, C-shell, or Bourne-shell scripts, which allows the re-use of existing scripts. The Tcl syntax is recommended; the resulting environment can be used on both UNIX and Windows systems, and Tcl supports aliases.
When necessary, the environment definition, written in any of the above languages, is automatically converted to use with Bourne-shell and the derivatives of Korn-shell and bash, C-shell and derivatives, Tcl scripts, and DOS prompt.
Each environment is described by the files shown in the following table. A minimal description of an environment consists of the start* script and the DOC file.
The .end* script is usually needed only for environments that are used with ves from the command line. The vovtasker binary caches eight recently used environments. When all eight cache slots are full and a new one is needed, the least-recently used environment is discarded without calling any of the .end* scripts.
path
. If environments are needed that exceed
those limits and tcsh is on the hosts, the .tcsh script suffix
can be used. Suffix | Language | Description |
---|---|---|
start.csh | C-shell | Initialization scripts, executed before entering the environment. If multiple scripts exist for the same environment, VOV will prefer in the following order, Tcl, C-Shell, Bourne-Shell, tcsh. |
start.sh | Bourne-shell | |
start.ksh | Korn-shell | |
start.tcl | Tcl | |
start.tcsh | tcsh | |
end.csh | C-shell | Termination scripts, read when exiting the environment. See comment above about choice of language |
end.sh | Bourne-shell | |
end.tcl | Tcl | |
end.tcsh | tcsh | |
pre.tcl | Tcl | Executed before the execution of the job. |
post.tcl | Tcl | Executed after the execution of the job. |
General Rules
- Minimal: The definition adds only the minimum number of variables necessary to correctly execute a certain class of tools.
- Incremental: It builds upon the original environment.
- Reversible: It is possible to restore the original environment.
Rules to Write Environments in c-shell
In this example, an environment is created. The environment is named
MYENV
, which contains the directory
/usr/local/bin in the path. The start script for this
environment is $VOVDIR/local/environments/MYENV.start.csh.
path
or the environment
variable PATH can
be set. An example follows:
# -- This is MYENV.start.csh
set path = ( /usr/local/bin $path )
MYENV
environment, the resulting PATH may contain
duplicates of /usr/local/bin. In the long run, it is possible
for the PATH
variable to exceed its maximum allowed length (about 1kB), which can be imposed by
some implementations of csh. vovenv OPERATION [-colon] wordlist
- Operation
- Description
- DELETE
- Deletes word from list.
- APPEND
- Adds the word at the end of the list.
- PREPEND
- Adds the word at the beginning of the list.
If -colon is used, the list is assumed to be colon-separated, as for
the environment variable PATH. Otherwise,
it is a space-separated list such as the C-shell variable path
;
Instead of -colon, -: can be written.
# -- This is a better MYENV.start.csh
set path = `vovenv PREPEND /usr/local/bin $path`
# -- This is MYENV.end.csh
set path = `vovenv DELETE /usr/local/bin $path`
Rules to Write Environments in Tcl
env()
. For
example, the value of the variable VOVDIR is
accessible as $env(VOVDIR)
. You also need to become familiar with
the following Tcl procedures supplied by
VOV:setenv name value
unsetenv name ...
vovenv name separator op arg ...
alias name words ...
These procedures look similar to their C-shell equivalent. In fact, they are Tcl procedures that are defined in $VOVDIR/tcl/vtcl/vovenvutils.tcl.
The procedures setenv and unsetenv behave as their C-shell counterparts. The procedure vovenv has the same functionality as the shell utility vovenv, but with a different syntax. Refer to the VOV/Tcl book for more information about these procedures.
Error handling: if errors are detected while processing of the environment definition, do not call exit. Instead, use the call error.
The environment MYENV
that was described in the previous section can
be described with the Tcl syntax as shown below.
# This is MYENV.start.tcl
vovenv PATH : PREPEND /usr/local/bin
# This is MYENV.end.tcl
vovenv PATH : DELETE /usr/local/bin
# This is MYENV.start.tcl
if { $::tcl_platform(platform) eq "windows" } {
# Quote ; because it is the command separator in Tcl.
vovenv PATH ";" PREPEND c:/local/bin
} else {
vovenv PATH : PREPEND /usr/local/bin
}
env(Temp)
and env(TEMP)
are distinct and only
one of the two can be used. If the value of an environment variable is needed, first
call the procedure nt_preprocess_env to create an upper-case only
version of the variable:
set tmpdir $env(TEMP) ;# May not work
nt_preprocess_env
set tmpdir $env(TEMP) ;# Guaranteed to work.
nt_preprocess_env
set tmpdir [nt_slashes $env(TEMP)]
Support for Aliases
Some customers desire the ability to define aliases in environments. Aliases are useful shorthands and reduce typing. They are useful only in command shells. Aliases are not used when taskers execute jobs.
To define an alias, you have to describe an environment using Tcl syntax. Aliases defined in the environment become available to the following shells: C-shell, Tcsh, Korn-shell. They are not available in Bourne-shell or in DOS.
alias NAME WORD ....
# At the end of $VOVDIR/local/environments/BASE.start.tcl
alias lll ls -sF
% ves BASE% alias lll
ls -sF
Pre and post Conditions
As part of environment definition, you can prepare two scripts, called NameOfEnv.pre.tcl and NameOfEnv.post.tcl, which can be used to take care of pre- and post-conditions on a job by job basis.