Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor change to text

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Introduction

Parameters can  can be set for Jobs and and for Orders.

Job parameters are defined for jobs and ordersare available every time the job is run.

Order parameters are defined for orders and are available to all the jobs in a job chain Job Chain. When the value of an order parameter in a job chain is changed then this new value will be applied at the next start of the next (persistent) order.

Note that when jobs are programmed using the JobScheduler API, job and order parameters are separate objects. Node and order parameters form the same object, although here node Order parameters have priority over order - i.e. will overwrite - job parameters of the same name.

Parameters allow a general purpose jobs to be created that are then provided with specific information via the parameters. For example, the file name, current location and target address for a file transfer job could be easily specified using parameters.

Parameters can be used to provide information for either shell jobs - i.e. jobs that run a shell script - or API jobs - i.e. jobs that use the JobScheduler's API Interface. The most widely used API jobs are the JITL - JobScheduler Integrated Template Library jobs that can be included as part of each JobScheduler installation and allow the JobScheduler to carry out a wide range of standard functions.

Article Delimitation

Global Variables

Parameters can be also be set from global variables. This is outside the scope of this article and described in:

Job Chain Node Parameters

Parameters can also be set for job chains and job chain nodes. However these parameters are used differently to job and order parameters and are not described in this article.

...

Setting Parameters for a Job or an Order in JOE

The Parameter function elements can be found in the JOE element JOE - JobScheduler Object Editor, in the Scheduler Elements tree as a sub-element elements of every Job job and Orderorder. Each parameter consists of a name and a value.

...

The next two code blocks show the XML generated by JOE for a typical simple job and for a simple order:

Code Block
languagexml
titleA simple job with parameters
<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>
    <run_time />
</job>
Code Block
languagexml
titleA simple order with parameters
<order  job_chain="shell_with_parameter" id="shell_with_parameterOrder1">
    <params >
        <param  name="param1" value="Value1-Order1"/>
        <param  name="param2" value="Value2-Order1"/>
    </params>

    <run_time />
</order>

...

Setting Parameters for an Order in

...

JOC

Parameters Order parameters can be read and set in shell scripts when they are mad available as environment variables

An environment variable of the form:

  • $SCHEDULER_PARAM_[PARAM-NAME] (Unix™)
  • %SCHEDULER_PARAM_[PARAM-NAME]% (Windows™)
    can be used to read any parameter in a shell script.

Parameters in a shell script can be added and modified using:

  • echo "[PARAM-NAME]=[PARAM-VALUE]" >> $SCHEDULER_RETURN_VALUES (on Unix™ systems)
  • echo [PARAM-NAME]=[PARAM-VALUE] >> %SCHEDULER_RETURN_VALUES% (on Windows™ systems)
    Check to see if the testParam parameter, described in the last chapter (page 28), has been set. As an example of the reading and writing of parameters, modify the scripts of the quickstart/firstOrderJob and quickstart/secondOrderJob Jobs as follows:

    Code Block
    titleA first order job for Windows
     @echo off
     echo %SCHEDULER_JOB_NAME% processed %SCHEDULER_ORDER_ID%
     echo Current Timestamp: %DATE% %TIME%
     echo Parameter testParam = "%SCHEDULER_PARAM_TESTPARAM%"
     echo Parameter testParam is modified to "123456789"
     echo testParam=123456789 >> %SCHEDULER_RETURN_VALUES%
     exit %ERRORLEVEL%
    

Example: firstOrderJob for Windows™

Code Block
titleA first order job for Unix
 #!/bin/sh
 echo "$SCHEDULER_JOB_NAME processed $SCHEDULER_ORDER_ID"
 echo "Current Timestamp: `date`"
 echo "Parameter testParam = \"$SCHEDULER_PARAM_TESTPARAM\""
 echo "Parameter testParam is modified to \"123456789\""
 echo "testParam=123456789" >> $SCHEDULER_RETURN_VALUES
 exit $?

Example: firstOrderJob for Unix™

Code Block
titleA second order job for Windows
 @echo off
 echo %SCHEDULER_JOB_NAME% processed %SCHEDULER_ORDER_ID%
 echo Parameter testParam = "%SCHEDULER_PARAM_TESTPARAM%"
 dir .\config\live\quickstart
 exit %ERRORLEVEL%

Example: secondOrderJob for Windows™

Code Block
titleA second order job for Unix
 #!/bin/sh
 echo "$SCHEDULER_JOB_NAME processed $SCHEDULER_ORDER_ID"
 echo "Parameter testParam = \"$SCHEDULER_PARAM_TESTPARAM\""
 ls -l ./config/live/quickstart
 exit $?

Example: secondOrderJob for Unix™

Both Jobs read the testParam parameter, whilst the quickstart/firstOrderJob Job changes the value of the
parameter. testParamHello World! is the initial parameter setting for the quickstart/firstOrderJob Job. This value will be overridden by the Order

Now start the Order for the quickstart/firstJobChain Chain in JOC and follow its progress in the log file.

JOC - JobScheduler Operations Center when an order start is configured.

This is done using the Order menu button as shown in the screenshot below.

Image Added

The Start order parametrized button opens the Start order shell_with_parameter form as shown in the next screen shot.

This form is used to specify a start time (or immediate start) for the order and any parameters

Image Added

The submit button will start the order at the time specified in the upper part of the form with the parameter name/value pair shown.

The new param button can be used to add a further name/value pair for the order.

A parameter set here will overwrite a parameter with the same name that has been configured for a job.

Using Parameters in Shell Script Jobs

  • Job and order Parameters are exposed to shell scripts as environment variables.
  • Environment variables are named using a predefined prefix and the name of the original parameter: 
    • The default value for the environment variable prefix is SCHEDULER_PARAM_ 
    • Environment variable names are provided with uppercase letters.
    • For example, a parameter param1 can be accessed by the SCHEDULER_PARAM_PARAM1 environment variable. This syntax applies for both job and order parameters.
    • For details see Which environment variables are provided by JobScheduler?

Examples for parameters defined for a job

The following two examples show a job parameter defined in a job <param> tag can be used in a shell script. Note that the parameter could have been equally well have been defined in the order.

Code Block
languagexml
titleExample for Windows showing how a task parameter can be used in a shell script
collapsetrue
 <job>
    <params>
        <param name="param1"  value="Test"/>
    </params>
    <script language="shell">
        <![CDATA[
 rem This is an example shell script to show the use of parameters
 echo Param1 has the value %SCHEDULER_PARAM_PARAM1%
        ]]>
    </script>
    <run_time/>
 </job>
Code Block
languagexml
titleExample for Unix showing how a task parameter can be used in a shell script
collapsetrue
 <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 "Parameter param1 has the value $SCHEDULER_PARAM_PARAM1"
        ]]>
    </script>
    <run_time/>
 </job

Examples for parameters defined on job start

The following example shows an XML command to start a job with parameters.

Code Block
languagexml
titleExample for Windows showing how a task parameter can be used in a shell script
collapsetrue
 <start_job job="my_job">
    <params>
        <param name="param1"  value="Test"/>
    </params>
 </start_job>
  • A parametrized job start can be used programmatically, e.g. by use of the JobScheduler start script.
  • Such parametrized job starts can be effected by JOC.

For further information see

Using Parameters in API Jobs

Job and order parameters are exposed to the API as objects.

This is described in detail in:

...

Further References

Job and Order Parameters

Parameters and Global Variables

 Job Chain Node Parameters

 Environment Environment Variables