exit

The exit command terminates the action and returns an integer value to the caller.

exit {integer exit code}

This command can employ relevance substitution. When it is executed, the value of the integer is transferred to the exit code inspector, and the action is terminated at that line. Exit codes can affect the ‘fixed’ status of run-to-completion actions by exiting from the script before the last line. If there are no executable lines after the exit command, the action will complete successfully. However, if there are other commands after the exit command, the run-to-completion action will fail.

In the IBM BigFix Console, the value of the last exit command is displayed in the View action Information dialog, along with other status information.

In a relevance expression, this value can be evaluated using the 'exit code of <action>' Inspector.

Syntax

exit <{expression}>

Where expression is the integer value to be passed back to the caller. This is limited to 32-bit signed numbers, however on Unix, the limit is 8 or 16 bits, which can be determined by running the WIFEXITED macro.

Example

wait 'foo'
parameter "error" = "{exit code of action}"
if {parameter "error" != "0"}
      exit {parameter "error"}
endif 
// continue processing

This example represents a a script that reports errors as non-zero exit codes. It allows you to terminate the script early and report the exit code to the caller. This is one of four script commands (wait, waithidden, waitdetached and exit) that can change the exit code inspector value. The three wait commands set the exit code according to the executable, with the OS limiting the size of the number. The exit command sets the exit code according to the number passed to it as a signed 32 bit number, regardless of the OS.

You may use the exit command in conjunction with DOS, however DOS can't set the exit code itself because of a limitation of the system command API.

Note for Unix shell scripts: For actions of type 'x-sh', the exit code of the script is collected into the inspector value when the client finishes processing a shell script. Exit codes from UNIX shell scripts are written to the client log.

Version 8.0