5.8.4 Defining commands that terminate normally
- Organization of this subsection
(1) Defining commands that terminate normally, even when the return code is not 0
You can specify a return code threshold for normal termination so that nonzero values as a command's return code will be treated as a normal termination. Any return code that does not exceed the specified threshold will cause the command to be treated as having terminated normally.
You can use the following environment setting parameters to specify a return code threshold.
CMDRC_THRESHOLD_USE_PRESET parameter
This parameter specifies a return code threshold for all UNIX-compatible commands. The permitted threshold specifications are 0 and 1.
cmp command
diff command
egrep command
expr command
grep command
sort command
For details, see 7.3.10 CMDRC_THRESHOLD_USE_PRESET parameter (defines a threshold for the return code of a UNIX-compatible command).
CMDRC_THRESHOLD_DEFINE parameter
This parameter specifies target commands and a return code threshold. You can specify the following commands:
External commands
UNIX-compatible commands
Shell scripts
Shell operation command
child jobs
For details, see 7.3.9 CMDRC_THRESHOLD_DEFINE parameter (defines a return code threshold for a command).
(2) Defining commands that always terminate normally
When the #-adsh_rc_ignore command is used, a command whose name is defined always terminates normally regardless of its return code. In such a case, the return code of the target command has no effect on the evaluation of the result of the job step (success or fail).
However, if the command is terminated by signal, the command always terminates with an error regardless of this specification.
The commands shown below will not result in an error even if their return code is not zero, which means that the return code is ignored regardless of the specification of this command:
true and false commands
The #-adsh_rc_ignore command definition takes effect on the execution of a job definition script starting at the location immediately following where this definition is specified. If this definition is specified outside a job step, it takes effect on the entire job definition script. If the definition is specified inside a job step, it takes effect only inside that job step. When the definition is specified inside a job step, it takes effect from the location immediately following the location of its specification through the end of the job step, and any value specified outside the job step becomes invalid temporarily. Until a value is specified inside the job step, a value specified outside the job step becomes valid.
The following shows an example specification:
01: #!/opt/jp1as/bin/adshexec 02: #-adsh_job JOB0001 03: 04: uap01 05: uap02 06: #-adsh_rc_ignore uap03,uap04 <--1. Specified outside the job step. 07: uap03 <--Scope of 1 is from line 07 through 14. 08: 09: #-adsh_step_start STEP1 10: uap04 11: #-adsh_step_end 12: 13: #-adsh_step_start STEP2 14: uap05 15: #-adsh_rc_ignore uap06,uap07 <--2. Specified inside the job step. 16: uap06 <--Scope of 2 is from line 16 through 17. 17: uap07 18: #-adsh_step_end 19: 20: #-adsh_step_start STEP4 <--Scope of 1 is from line 20 through 22. 21: uap08 22: #-adsh_step_end
(3) Priority of functions that normally terminate even if the return code is other than 0
The priority when specifying the CMDRC_THRESHOLD_DEFINE parameter, the #-adsh_rc_ignore command, the successRC attribute of #-adsh_step_start, and the adshcmdrc command simultaneously is shown below. The smaller number indicates higher priority. If the command that is the target of the CMDRC_THRESHOLD_USE_PRESET parameter, the priority of the CMDRC_THRESHOLD_USE_PRESET becomes "7".
1. #-adsh_rc_ignore command defined in the job step 2. #-adsh_rc_ignore command defined outside the job step 3. adshcmdrc command defined in the job step 4. successRC attribute of #-adsh_step_start 5. Adshcmdrc command defined outside the job step 6. CMDRC_THRESHOLD_DEFINE parameter 7. CMDRC_THRESHOLD_USE_PRESET parameter
The example if each function that normally terminates even if the return code is other than 0 is defined for command of command name is as follows:
- Job definition script
-
#-adsh_rc_ignore Command name ...2 adshcmdrc Command name 1 ...5 #-adsh_step_start STEP1 -successRC 2 ...4 #-adsh_rc_ignore Command name ...1 adshcmdrc Command name 3 ...3 Command name #-adsh_step_end
- Environment file
-
#-adsh_conf CMDRC_THRESHOLD_DEFINE Command name 10 ...6