Previous Topic

Next Topic

Book Contents

Book Index

Utilization of exit codes

Both DOS .bat scripts and REXX .cmd scripts can return an exit code to Control-M/Server upon completion. The_exit script utility is used by .bat scripts. For more information about script utilities, see Definition, ordering, and monitoring utilities in Control-M Utilities.

Control-M/Server can distinguish between exit codes by using the following expression in the Code sub-parameter of the On Statement/Code job processing parameter:

COMPSTAT=<value>

EXAMPLE: Using exit codes

In this example, a REXX script exits with an exit code of 5, as displayed below:

exit 5

This condition can be detected by defining the following On Statement/Code parameter:

Stmt: *

Code: COMPSTAT=5

EXAMPLE: Job ends with a status of NOTOK

Using the following commands, any completion code other than 2 causes the job to end with a status of NOTOK.

On

Statement *

Code  COMPSTAT!2

Do NOTOK

EXAMPLE: Job ends with a status of OK

Using the following commands, any even completion code causes the job to end with a status of OK.

On

Statement *

Code COMPSTAT EQ EVEN

Do OK

Example: Create a condition on NOTOK

Using the following commands, a completion status of NOTOK causes Control‑M to create a condition.

On

Statement *

Code NOTOK

Do Cond PRKZ_NOTOK ODAT +

EXAMPLE: Output from a UNIX Job

Assume that the following messages are issued from a UNIX job:

+ date

Mon Mar 20 10:30:58 IST 2006

+ pwd

/export/users/ctmagent

+ ls

BMCINSTALL

ctm

installed-versions.txt

lsagent.sh

The following On statement would be triggered by the preceding messages:

ON

Statement ls

Code lsagent*

Do NOTOK

EXAMPLE: Rerunning a job (for Microsoft Windows)

Assume that the following is the Output from a batch job:

copy job411.dat tempt.dat

File not found - JOB411.DAT

0 file(s) copied

The following On statement would be triggered by the preceding job output:

On

Statement copy job411.dat

Code File not found

Do Rerun

EXAMPLE: Assign NOTOK status for an IBM i (AS/400) job

Assume that the following is the Output from an IBM i (AS/400) job:

*NOnE Request 21/11/05 16:41:07 QWTSCSBJ QSYS 02FF TEST CMTST 0009

Message . . . . : -CALL PGM(CMTST)

CPD0170 Diagnostic 30 21/11/05 16:41:07 QCLCLCPR QSYS 02FF TEST CMTST 009

Message . . . . : Program CMTST in library *LIBL not found.

Cause . . . . . : The Program specified on the CALL command

cannot be found.

The following On statement would be triggered by the preceding job output:

On

Statement *CALL PGM (CMTST)*

Code *Program CMTST in library *LIBL not found.*

Do NOTOK

Issue a shout

In this example a shout is issued to the administrator if the word "error" is displayed anywhere in the Output.

On

Statement stmt= * code= *error*

Do Shout To= Adman Urgn= High Msg= Potential error in Job %%jobid

EXAMPLE: Using completion codes other than 2

A completion code other than 2 causes the job to end NOTOK.

On

Statement stmt= * code= COMPSTAT !2

Do NOTOK

EXAMPLE: Using even completion codes causes the job to end OK

Any even completion code causes the job to end OK.

On

Statement stmt= * code= COMPSTAT EQ Even

Do OK

EXAMPLE: Trigger a second job after the first job ends NOTOK

If a job ends NOTOK, add a condition that triggers a job that now becomes necessary.

On

Statement stmt= * code= NOTOK

Do Condition Name=JobX_NotOK Date= odat sign= +

EXAMPLE: Set the status of a job to NOTOK under certain conditions

Set the status of a job to NOTOK if the Output indicates that the password directory is not found, In such a case, the Output of the UNIX job contains text similar to the following:

cp /etc/passwd /tmp

cp /etc/passwdx /tmp

cp: /etc/passwdx: No such file or directory

cp /etc/passwd /usr/kvm/xyzzy

cp: /usr/kvm/xyzzy: Permission denied

exit 12

On

Statement stmt= cp/etc/passwdx/tmp code= cp*no*file

Do NOTOK

EXAMPLE: Rerun a job under certain conditions

Rerun the job if the Output indicates that a particular file to be copied was not found:

On

Statement stmt= copy job411.dat code= File not found

Do Rerun

Parent Topic

On/Do Actions