Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
...
Accessing parameters in shell scripts
- Environment variables are used to make job (i.e. task) Job and order parameters accessible are exposed as environment variables to shell scripts in subsequent jobs.
- Environment variables are named using a predefined prefix and the name of the original parameter:
- Environment variable names are written with uppercase letters.
- The default value for the environment variable prefix is is SCHEDULER_PARAM_ .
- Environment variable names are provided with uppercase letters.
- For example, a task parameter param1 can be accessed by the SCHEDULER_PARAM_PARAM1 environment variable name.
For details see Which environment variables are provided by JobScheduler?
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<job> <params> <param name="param1" value="Test"/> </params> <script language="shell"> <![CDATA[ # This is an example shell script to show the use of parameters echo "Param1Parameter param1 has the value $SCHEDULER_PARAM_PARAM1" ]]> </script> <run_time/> </job |
To use parameters as command line arguments for a script add environment variables as arguments in the command line as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
anyshellscript.sh $SCHEDULER_PARAM_PARAM1 $SCHEDULER_PARAM_PARM2 ... |
...
Passing parameters to subsequent shell jobs in a job chain
- JobScheduler allows the creation or overwriting of order parameters for subsequent jobs in a job chain.
- JobScheduler parses a temporary file for name/value pairs each time the status of after termination of each job in a job chain changes.
- The name of this temporary file is held in the SCHEDULER_RETURN_VALUES environment variable.
- The name/value pairs are automatically added as order parameters.
- A parameter set in one job shell script can be written to this temporary file and made available to subsequent jobs using the following (for Windows):
myParam=myValue >> %SCHEDULER_RETURN_VALUES%
- A task parameter set in one job can be written to this temporary file and thereby made available to subsequent jobs in a job chain using the following (for Windows):
myParam=%SCHEDULER_PARAM_MYPARAM% >> %SCHEDULER_RETURN_VALUES%
- A parameter set in one job is called in the shell script of a Such parameters are accessible in subsequent job using the following (for Windows):
echo myParam = %SCHEDULER_PARAM_MYPARAM%
The following code blocks show two jobs that demonstrate the setting and retrieval of shell script parameters in a job chain:
Code Block | ||||
---|---|---|---|---|
| ||||
<job order="yes" stop_on_error="no" name="job1_shell_with_parameter_set"> <params> <param name="param1" value="Value1-Job1" /> <param name="param2" value="Value2-Job1" /> </params> <script language="shell"> <![CDATA[ rem This is a sample shell script to demonstrate the setting of parameters echo param1 = %SCHEDULER_PARAM_PARAM1% echo param2 = %SCHEDULER_PARAM_PARAM2%PARAM2% rem creating order parameters for subsequent jobs echo param2 = some-other-value >> %SCHEDULER_RETURN_VALUES% echo param3 = Value3 >> %SCHEDULER_RETURN_VALUES% ]]> </script> <run_time/> </job> |
...