1

在 Autosys 中,我有一个执行相当简单的 DOS 批处理文件 (.CMD) 的作业。如果作业有条件地失败,我如何与 Autosys 沟通?如果它运行并终止,Autosys 无论如何都会报告成功。如果脚本根据内部确定的条件失败,我想以编程方式告诉 Autosys。

任何帮助,将不胜感激。提前致谢。

4

2 回答 2

2

您可以使用 ERRORLEVEL,打开一个 DOS 框并输入 'help if' 这些位是相关的:

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
于 2010-10-31T18:59:20.057 回答
1

您需要做的是 .bat 文件的最后一行应该显示以下内容:

EXIT /B %ErrorLevel%
于 2011-05-05T12:31:36.287 回答