Using the CSH Definition Type
The C shell is an alternative UNIX shell on various UNIX systems such as AIX, HP-UX and Solaris. It is also available on Linux and Microsoft Windows.
For compatibility with the CSH definition type on Windows and Linux, you must install tcsh
separately if it is not already installed.
note
You must assign at least one process server to run CSH process definitions in order to use the definition type.
Interpreter
By default, the interpreter for CSH scripts defaults to /bin/csh
on most platforms. You can override this by specifying an interpreter on process server-level with the LocalInterpreter_CSH
process server parameter, such as /usr/local/bin/csh
, for example. You can also specify a list of allowed interpreters on process server-level using the InterpreterWhitelist_CSH
process server parameter and override the default interpreter on process definition-level with the parameter JCS_INTERPRETER_CSH
. Simply create the parameter and point it to your preferred interpreter, it must exist and be white-listed using the InterpreterWhitelist_CSH
process server parameter.
The InterpreterWhitelist_CSH
process server parameter takes a regular expression that must match the value of the JCS_INTERPRETER_CSH
process parameter.
Should you use C Shell scripts
CSH is not recommended to code new scripts in. It is not possible to store all possible values in C Shell variables, and it does not support functions or other structured programming concepts very well. A well known article explaining this in more detail can be found by searching the internet for 'CSH programming considered harmful'.
We still offer the CSH definition type for those cases where you have historic code written in the C shell that needs to be executed as a process. It is highly recommended that for new code you use the BASH, KSH, or Perl definition types instead of CSH.
Predefined variables and profile
See Using Platform Definition Types for more information regarding the predefined variables.
Variables and Parameters
- Parameters in the process definition are manipulated in the CSH source simply as variables, using the standard
$PARAMETER
syntax. - The CSH shell variables do not have actual data types; all parameter values are stored as strings. Numbers are translated automatically. Dates are sent and retrieved using the Script Date Format.
- Out parameters are supported by setting the parameter using the
set PARAMETER=VALUE
or@ PARAMETER = VALUE
syntax.
Returning an Error
If your script code exits with a non-zero exit code this is correctly reflected in the server. When a CSH script returns with a non-zero error code, the output parameters are not set.
CSH Examples
The following shows how to use a normal environment variable:
echo "This is running under user $USER with home directory $HOME and temporary directory $TMPDIR."
The following shows how to pass numeric (N1), string (S1) and date (D1) parameters to and from CSH scripts:
# Add numeric variable to itself
@ N1 = $N1 + $N1
# Concatenate string
set S1="$S1 $S1"
set DTEMP="1999/12/31 23:59:59,000 GMT"
echo You said $D1, I propose $DTEMP
# Set DateTime to new string value
set D1="$DTEMP"
The following example shows you how to return a non-zero exit code resulting in the process going into Error:
set N=1
echo "Exiting with value $N."
if ( $N > 0 ) then
exit $N
endif
echo "Not reached"