Setting a user variable in a Windows bat file

This method requires a shared filesystem. The jfd work directory must be on a shared filesystem accessible by all your jobs. Within the batch file, set the values and scopes of multiple variables by specifying the files containing these variables. The jobs write to the files in the following format, with each line containing a variable-value pair.

About this task

VARIABLE1=VALUE1
VARIABLE2=VALUE2
...

Process Manager will not initially create these files — the files need to be created by the job.

For job arrays, you must append the LSB_JOBINDEX environment variable to the file names to indicate the index of each job array element.

Procedure

  1. Define a job that runs a batch file, or wraps the command to run within a batch file.
  2. Within the batch file, set the scope of the variable by specifying the variable-value pair in the scope-specific file, as follows:
    1. To set local variables, whose values are not available outside the scope of this flow (or subflow), from a file, use the JS_FLOW_VARIABLE_FILE environment variable to access the file.
      • To set a local variable-value pair for a job, append to the %JS_FLOW_VARIABLE_FILE% file:

        echo variable=value > %JS_FLOW_VARIABLE_FILE%

      • To set a local variable-value pair for a job array, append to the %JS_FLOW_VARIABLE_FILE%[%LSB_JOBINDEX%] file:

        echo variable=value > %JS_FLOW_VARIABLE_FILE%[%LSB_JOBINDEX%]

    2. To set global variables, whose values are available to all flows within the Process Manager Server, from a file, use the JS_GLOBAL_VARIABLE_FILE environment variable to access the file.
      • To set a global variable-value pair for a job, append to the %JS_GLOBAL_VARIABLE_FILE% file:

        echo variable=value > %JS_GLOBAL_VARIABLE_FILE%

      • To set a global variable-value pair for a job array, append to the %JS_GLOBAL_VARIABLE_FILE%[%LSB_JOBINDEX%] file:

        echo variable=value > %JS_GLOBAL_VARIABLE_FILE%[%LSB_JOBINDEX%]

    3. To set parent flow variables, whose values are available to the scope of the parent flow for this flow (or subflow), from a file, use the JS_PARENT_FLOW_VARIABLE_FILE environment variable to access the file. If this flow is the main flow, the parent flow is also the main flow.
      • To set a parent variable-value pair for a job, append to the %JS_PARENT_FLOW_VARIABLE_FILE% file:

        echo variable=value > %JS_PARENT_FLOW_VARIABLE_FILE%

      • To set a parent variable-value pair for a job array, append to the %JS_PARENT_FLOW_VARIABLE_FILE%[%LSB_JOBINDEX%] file:

        echo variable=value > %JS_PARENT_FLOW_VARIABLE_FILE%[%LSB_JOBINDEX%]

Results

Process Manager sets the file environment variables as follows:

  • Process Manager sets %JS_FLOW_VARIABLE_FILE% to JS_HOME\work\var_comm\flowvar.job_name.

  • Process Manager sets %JS_GLOBAL_VARIABLE_FILE% to JS_HOME\work\var_comm\globalvar.job_name.

  • Process Manager sets %JS_PARENT_FLOW_VARIABLE_FILE% to JS_HOME\work\var_comm\parentflowvar.job_name.

Within the appropriate scope, Process Manager reads these files and records the variable-value pairs to the corresponding variable list environment variable (for example, %JS_FLOW_VARIABLE_LIST% for local variables or %JS_GLOBAL_VARIABLE_LIST% for global variables)