IBM i from Windows, UNIX, or IBM i - exec Command Return Codes

IBM i from Windows, UNIX, or IBM i - exec Command Return Codes

This example demonstrates using the _execrc built-in variable.

For IBM i, the UCMD Server checks the error severity for each CL command issued. If the severity of the error exceeds the value set via the UCMD Server END_SEVERITY option, the value is returned via _execrc. A UCMD Server error may also result in _execrc being set. If no error occurs, _execrc is zero.

Generally, UCMD Server return codes for IBM i are 200 or greater. Therefore, return codes associated with END_SEVERITY and with the UCMD Server do not conflict.

The svropt parameter passes options to the UCMD Server. These options override both the defaults and the options contained in the UCMD Server configuration file. The -joblog never value prevents the job log from being returned to the transaction log via stdout. (Do not include svropt if you want the job log.) The spaces before and after the double quotation marks are significant. END_SEVERITY can also be overridden.

The exec commands are both broken into two lines. The - and + characters are line continuation characters. Using - trims all leading blanks from the beginning of the next line; using + retains the blanks. In the example script, only one blank remains to separate the text on the two lines after they are concatenated.

This UDM example script was tested on three different platforms: Linux, Windows XP, and IBM i.

1. set echo=yes
2. exec atlanta cmd="SAVLIB LIB(NONAME) DEV(*SAVF) SAVF(QGPL/ABC)" user=joe -
    pwd=abcdefg port=27887 svropt=" \-joblog never "
3. echo "rc = " $(_execrc)
4. if $(_execrc) GE 30
5. exec atlanta cmd="SNDMSG MSG('The command, SAVLIB LIB(NONAME) DEV(*SAVF) -
    SAVF(QGPL/ABC), failed') TOUSR(*SYSOPR)" user=joe pwd=abcdefg port=27887 svropt=" \-joblog never "
6. end
7. quit

UDM Script Explanation

The script issues an IBM i command that fails and, based on the failure, issues an IBM i command to notify the system operator.

  1. Turns echo on.
  2. Issues a SAVLIB command to system atlanta which fails with end severity 40.
  3. Echoes the value returned to the UDM Manager from the system via the UCMD Server.
  4. Checks for the error.
  5. Issues the SNDMSG command to notify the system operator.
  6. Closes the if statement.
  7. Cleans up and exits the UDM script.

Operating System-Specific Information

Although the same script works equally well on Windows, UNIX, and IBM i, the syntax for submitting the script differs.

Windows and UNIX

The syntax is udm -s script-path.
To run the example, change the current directory to the location of the script and issue udm -s xmp0.udm, where xmp0.udm is the name of the file containing the script.

IBM i

The syntax is STRUDM qualified-file-name file-member-name.
To run the example, enter STRUDM joe/qscrsrc xmp0_udm. The file and member names are positional parameters. STRUDM SCRFILE(JOE/QSCRSRC) SCRMBR(XMP0_UDM) is also valid.

UDM exec Command Parameters

The exec command parameters used in this example are:

Parameter

Description

cmd Command Reference file name and, optionally, options to be passed to the command or script.

user

Remote user ID with which to authenticate and execute the command on the remote system.

pwd

Password with which to authenticate the user ID on the remote system.

port

Port that the Universal Broker is listening on for the remote machine. The port is inherited from the UDM Manager's configuration file unless explicitly overridden in the call to the exec command.

svropt

Server option to pass to the UCMD server.

Components

Universal Data Mover Manager for IBM i

Universal Data Mover Manager for Windows

Universal Data Mover Manager for UNIX

Universal Command Manager for IBM i