views:

14

answers:

1

In Autosys, I have a job that executes a fairly simple DOS batch file (.CMD). How do I communicate back to Autosys if the job has conditionally failed? If it runs and terminates, Autosys reports a success no matter what. I would like to programmatically tell Autosys if the script failed based on conditions determined within.

Any help would be appreciated. Thanks in advance.

+1  A: 

You can use ERRORLEVEL, open a DOS box and type 'help if' These bits are relevant:

C:\help if
Performs conditional processing in batch programs.

IF [NOT] ERRORLEVEL number command
IF [NOT] string1==string2 command
IF [NOT] EXIST filename command

  NOT               Specifies that Windows should carry out
                    the command only if the condition is false.

  ERRORLEVEL number Specifies a true condition if the last program run
                    returned an exit code equal to or greater than the number
                    specified.


%ERRORLEVEL% will expand into a string representation of
the current value of ERRORLEVEL, provided that there is not already
an environment variable with the name ERRORLEVEL, in which case you
will get its value instead.  After running a program, the following
illustrates ERRORLEVEL use:

    goto answer%ERRORLEVEL%
    :answer0
    echo Program had return code 0
    :answer1
    echo Program had return code 1
NickT