Using the CSH Definition Type
The C shell is an alternative UNIX shell on systems such as AIX, HP-UX, and Solaris. It is also available on Linux and 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 by setting the LocalInterpreter_CSH
Process Server parameter to, for example, /usr/local/bin/csh
. 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 at the Process Definition level with the parameter JCS_INTERPRETER_CSH
. Simply create the parameter and point it to your preferred interpreter. The interpreter must be whitelisted using the InterpreterWhitelist_CSH
Process Server parameter, which takes a regular expression that must match the value of the JCS_INTERPRETER_CSH
process parameter.
C Shell (CSH) Scripts
CSH is not recommended for new scripts. It is not possible to store all possible values in CSH variables, and CSH does not support functions and other structured programming concepts very well. However, Redwood still offers 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. Redwood recommends that for new code, you use the BASH, KSH, or Perl Definition Types instead of CSH.
Predefined Variables and Profile
For more information regarding predefined variables, see Using Platform Definition Types.
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.
Examples
This example shows how to use a normal environment variable.
echo "This is running under user $USER with home directory $HOME and temporary directory $TMPDIR."
This example 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"
This example shows you how to return a non-zero exit code, resulting in the process going into Error
status.
set N=1
echo "Exiting with value $N."
if ( $N > 0 ) then
exit $N
endif
echo "Not reached"