Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

User Parameters in Shell Scripts

Job parameters and order parameters are accessible by use of environment variables. There is a naming convention: the name of the environment variable according to a parameter is SCHEDULER_PARAM_NAMEOFPARAM. For example the job parameter param1 is available by the environment variable SCHEDULER_PARAM_PARAM1.

Windows

Code Block
 <job>
    <params>
        <param name="param1"  value="Test"/>
    </params>
    <script language="shell">
        <![CDATA[
 rem This is a sample shell script to demonstrate the use of parameters
 echo Param1 has the value %scheduler_param_param1%
        ]]>
    </script>
    <run_time/>
 </job>

Unix

Code Block
 <job>
    <params>
        <param name="param1" value="Test"/>
    </params>
    <script language="shell">
        <![CDATA[
 # This is a sample shell script to demonstrate the use of parameters
 echo Param1 has the value $SCHEDULER_PARAM_PARAM1
        ]]>
    </script>
    <run_time/>
 </job

Setting parameters and making them accessible to the next node in a job chain

At every change of status in a job chain JobScheduler parses a temporary file for name/value pairs. These name/value pairs will be set as order params. The name of the temporary file is availabe with the environment variable SCHEDULER_RETURN_VALUES.

First Job

Code Block
 <job order="yes"
     stop_on_error="no">
    <params>
        <param name="param1"  value="Test"/>
    </params>
    <script language="shell">
        <![CDATA[
 rem This is a sample shell script to demonstrate the use of parameters 
 echo newParam=a sample value >> %scheduler_return_values%
        ]]>
    </script>
    <run_time/>
 </job>

Second Job

Code Block
 <job order="yes"
     stop_on_error="no">
    <params>
        <param name="param1" value="Test"/>
    </params>
    <script language="shell">
        <![CDATA[
 echo newParam has the value %scheduler_param_newParam%
        ]]>
    </script>
    <run_time/>
 </job>

Job Chain

Code Block
 <job_chain>
    <job_chain_node state="100"
                    job="job_sample_shell_with_parameter"
                    next_state="200"
                    error_state="error"/>
    <job_chain_node state="200"
                    job="job_sample_shell"
                    next_state="success"
                    error_state="error"/>
    <job_chain_node state="success"/>
    <job_chain_node state="error"/>
 </job_chain>