Summary

This article describes how to use a script to interpret exit codes from a process run by adTempus.

Background

When you run a process using a Program Execution Task in adTempus, the Success Criteria rules on the Advanced page of the step properties determine how adTempus knows whether the program succeeded. In most cases, you will be able to use one of the simple exit code rules. For example, most programs will return "0" for success and some value greater than 0 for a failure. Some programs may return "0" for success, "4" for a warning, or "8" for an error.

However, some programs may use an exit code scheme that cannot be accommodated by a simple rule. For example, consider a program that has possible exit codes of 1, 2, 3, 23, 45, and 67, with exit codes 23 and 67 indicating success, and all others indicating failure. For such a scheme you can use a simple script to interpret the exit code and tell adTempus whether the program succeeded or failed.

Procedure

On the Advanced page of the step properties, select the "Use a script" option in the Success Criteria section. Click Select... then New... to create a new script.

Make sure that "VB.NET" is selected as the script Language, then replace the default script code with the following:

Imports System
Imports System.Collections
Imports ArcanaDevelopment.adTempus.Server

Public Class UserScript
    Inherits ArcanaDevelopment.adTempus.ScriptEngine.UserScriptBase

    Public Overrides Function Run() As Object
    'The ProcessExitCode variable contains the exit code from the program that was just run
    'The script must examine the exit code and return a True value if the step should be reported as successful
    'or False if it should be reported as failed.
		Select Case CInt(adTempus.JobVariables("ProcessExitCode"))
			Case 23,67
				Return True
			Case Else
				Return False
        End Select
    End Function
End Class

Modify the "Case" line as necessary to specify the exit codes that represent successful execution (in this example, 23 and 67). Note that all

After adTempus runs the program, it stores the program's exit code in a Job Variable named ProcessExitCode and then runs the script.

The script retrieves the ProcessExitCode variable and returns a result based on its value. The script returns True if the exit code represents success, or False if it represents failure. In this example, the script returns True (success) for exit codes 23 and 67, and False (failure) for anything else.

Based on the result of the script, adTempus reports the step as either successful or failed.