Hitachi

JP1 Version 11 JP1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide 


5.5.4 Shell variable in which to set the return code of an external command [Windows only]

In JP1/Advanced Shell, the return code of an external command run by the job controller is set in the ADSH_RC_EXTERNAL shell variable.

Organization of this subsection

(1) ADSH_RC_EXTERNAL shell variable

We recommend that you use a number from 0 to 255 for the return code of an external command run by the job controller of JP1/Advanced Shell. However, in a case where a batch file or program ends with a return code outside the range from 0 to 255, judge the execution result from the return code by using the ADSH_RC_EXTERNAL shell variable. The following table describes the ADSH_RC_EXTERNAL shell variable, and shows the range of values that can be set in the shell variable.

Table 5‒36: Description and value range of the ADSH_RC_EXTERNAL shell variable

Shell variable name

Description

Value range

ADSH_RC_EXTERNAL

The return code of the last run external command is set. When one of the following commands is run in the job definition script, the job controller updates the value of the ADSH_RC_EXTERNAL shell variable.

  • External command

  • UNIX-compatible command

  • Shell operation command

  • Child job

The value of the shell variable is also updated when a command is run by another process (by using a pipe, command replacement, |&, or &). This shell variable is a read-only integer type, with an initial value of 0.

-2147483648 to 2147483647

(2) Examples

The following shows examples of using the ADSH_RC_EXTERNAL shell variable.

In the following example, the shell variable stores a value returned by an external command that is outside the range from 0 to 255.
"D:\\bin\\uap01.exe"    ... User program that ends with a return code of 800
echo $?                 ... 32 is output to the standard output.#
echo $ADSH_RC_EXTERNAL  ... 800 is output to the standard output.

#: 800 = 0x320 The ? shell variable handles the low-order eight bits of the value returned by an external command as the return code.

In the following example, if an external command returns 512, the job ends with a return code of 2.
"D:\\bin\\uap02.exe"
if [ $ADSH_RC_EXTERNAL -eq 512 ]
then
  exit 2
fi

(3) Notes