Using the OS Native Definition Type
The OS Natvie definition type uses the default shell of the user the process runs as. You specify your code to run directly in the source field just like a CMD or Bash definition type.
note
You must assign at least one process server to run OS Native process definitions in order to use the definition type.
Variables and Parameters
- Parameters in the process definitions are manipulated in the shell source simply as variables, using
:PARAMETER
or the standard target system syntax (Windows%PARAMETER%
or UNIX$PARAMETER
).- A third method for specifying parameters is the REL syntax
parameters.PARAMETER
(available if the source is REL and starts with=
)
- A third method for specifying parameters is the REL syntax
- Out parameters are supported by setting the parameter using the native syntax for your shell. For example
set PARAMETER1=value
on Windows/CMD and UNIX/csh, orPARAMETER1=value
on UNIX/sh. Consult the documentation for the default command line interpreter on your platform for more information.
When you specify:PARAMETER
and the parameter PARAMETER
does not exist, the string is passed as such to the shell.
Note that parameters with multi-line values to be executed should be specified using the REL syntax (for example parameters.P_MULTILINE_COMMANDS
).
Returning an Error
If your script code exits with a non-zero exit code this is correctly reflected in the server.
Code a shell-specific exit command ( set -e
in Bourne-based shells, exit /b
on Windows) to abort script execution immediately on running a command that has a non-zero exit status.
OS Independent
You use the osFamily
parameter to determine the type of OS you are running on (Windows, UNIX, VMS) using REL and have the right shell execute the right code, regardless of which platform the OS process; runs on.
Examples
Echoing parameters:
echo Hello :NAME
='echo Hello ' + Logic.case(osFamily, 'windows', '%NAME%', 'unix', '${NAME}', ':NAME')
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.
echo '+osFamily+'
echo '+parameters.Parameter1+'
echo ':Parameter2'
The following shows how to pass numeric (N1), string (S1) and date (D1) parameters to and from BASH scripts:
='# Note BASH allows no spaces around = in variable assignment
N1=$((expr $N1 + $N1)) # Add numeric variable to itself
S1=":S1 :S1" # Concatenate string
DTEMP="2023/11/16 23:59:59,000 GMT"
echo You said:D1, I propose:DTEMP
D1=:DTEMP # Set DateTime to new string value'
The following example shows you how to return a non-zero exit code resulting in the process going into Error:
='N=1
echo "Exiting with value :N."
exit:N
echo "Not reached"'
The following example shows you how to use RedwoodExpressionLanguage to detect the underlying operating system and list the contents of the current directory:
=Logic.case(osFamily, 'windows', 'dir', 'unix', 'ls', 'dir')