Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


5.5.1 Shell variables set by JP1/Advanced Shell

The table below lists and describes the shell variables set by JP1/Advanced Shell. Do not set values for, change attributes of, or release settings of these shell variables.

Table 5‒31: Shell variables that are set by JP1/Advanced Shell

Shell variable name

Value that is set

#

Number of arguments passed to the current job definition script or function.

-

An abbreviated character string of a shell option set in the shell.

A shell option that does not have an abbreviation is not set in this variable.

?

Return code of the immediately preceding command that was executed.

$

The process ID of the following program is set as the shell's process ID:

(Windows only)

Process ID of adshexecsub.exe or adshesub.exe

(UNIX only)

Process ID of adshexec

_

Value at the time the adshexec command starts. If no value exists, the contents of argv[0] at the time the adshexec command starts are set.

When an external command or child job is started as a child process, the contents of argv[0] are set.

!

Process ID of the last command that executed in the background.

ADSH_DIR_BIN#1

Path name of the JP1/Advanced Shell program folder (bin).#2

ADSH_DIR_CMD#1

Path name of the folder for JP1/Advanced Shell's UNIX-compatible commands (cmd).#3

ADSH_RC_STEPLAST#1

Return code of the most recent job step to have executed.

If no job steps have executed, the shell variable is undefined.

ADSH_RC_STEPMAX#1

Maximum value among the return codes of all job steps that have executed in the past.

If no job steps have executed, the shell variable is undefined.

ADSH_RC_STEPMIN#1

Minimum value among the return codes of all job steps that have executed in the past.

If no job steps have executed, the shell variable is undefined.

ADSH_STEPRC_job-step-name#1

Return code of the job step whose name is indicated. If the job step with the indicated job step name has not executed, the shell variable is undefined.

If there are duplicate job step names, the return code of the last job step executed is stored.

LINENO

Line number in the job definition script of the line that is executing currently.

OLDPWD

Immediately preceding work directory that was set by the cd command.

OPTARG

Value of the last option argument that was processed by the getopts command.

OPTIND

Index of the last option argument that was processed by the getopts command.

PPID

In Windows, the value is always 0.

In UNIX, the number of the shell's parent process is set.

PWD

Current work directory.

RANDOM

A random integer in the range from 0 through 32767 (= 0x7FFF).

REPLY

The data read by the read command with no arguments specified.

SECONDS

Number of seconds that have elapsed since the shell started.

Function information arrays#1

One-dimensional arrays of information about the function being executed by the adshexec command. The following arrays are supported:

  • Called function name array

  • Function call line number array

  • Function definition script file name array

For details about the function information arrays, see 5.5.3 Arrays of function information.

#1

These shells that have a special meaning are referred to collectively as the extended shell variables.

#2

The following is a definition example that uses the adshfile command in job definition scripts:

"${ADSH_DIR_BIN}adshfile" -s job -n keep -a del ${VAL01}
#3

The following is a definition example that uses the expr command in job definition scripts:

num=`"${ADSH_DIR_CMD}expr" $NUM - 1`

The following shows usage examples of these shell variables.

This example checks conditions by using the if script control statement and controls the execution of a job step based on the execution results of the preceding job step:
#!/opt/jp1as/bin/adshexec
#-adsh_job JOB001
#-adsh_step_start STEP01
    uap01
#-adsh_step_end
if [[ $ADSH_STEPRC_STEP01 -eq 0 ]]; then   <-- Execute STEP02 only if the return code of STEP01 is 0.
    #-adsh_step_start STEP02
        uap02
    #-adsh_step_end
fi
This example terminates the job definition script with the maximum job step return code value when the exit command is used to terminate the job definition script:
#!/opt/jp1as/bin/adshexec
#-adsh_job JOB001
 
#-adsh_step_start STEP01
  uap01
#-adsh_step_end
 
#-adsh_step_start STEP02 -run always
  uap02
#-adsh_step_end
 
#-adsh_step_start STEP03 -run always
  exit $ADSH_RC_STEPMAX        <-- Use the maximum job step return code value as the job's return code.
#-adsh_step_end