CommandRunner 实用程序作业步骤

使用 CommandRunner 实用程序作业步骤将 Shell 命令行作为作业步骤来运行。Shell 命令行可以包括 Shell 命令、Shell 脚本和已编译程序。

CommandRunner 实用程序运行操作系统进程中指定的 Shell 命令行。将捕获标准输出和标准错误流并将其写入作业日志。将捕获命令行返回码并将其设置为步骤返回码。如果取消了作业步骤,那么返回码为 -8

命令语法

对于 CommandRunner 实用程序,请使用以下语法:
<job-step name={step_name}>
<classname>com.ibm.websphere.batch.utility.CommandRunner</classname>
{job_step_properties}
</job-step>
例如,以下作业步骤代码运行命令行 Java™ 程序:
<job-step name="RunJava">
<classname>com.ibm.websphere.batch.utility.CommandRunner</classname>
<props>
<prop name="com.ibm.websphere.batch.cmdLine" 
      value="java.exe com.ibm.websphere.batch.samples.TestCase" />
<prop name="CLASSPATH" value="${user.dir}\testcases;${user.dir}\bin" />
<prop name="Path" value="${java.home}\bin;${env:Path}" />
</props>		
</job-step>

必需的作业步骤属性

以下属性是 CommandRunner 实用程序作业步骤的必需属性。
com.ibm.websphere.batch.cmdLine
指定命令行调用(包括参数)。
例如,将 java.exe 文件运行为命令行:
<prop name="com.ibm.websphere.batch.cmdLine" 
          value="java.exe com.ibm.websphere.batch.samples.TestCase" />

可选作业步骤属性

以下属性是 CommandRunner 实用程序作业步骤的可选属性。
com.ibm.websphere.batch.workingDir
指定在其中运行指定的命令行的工作目录。
例如,启用 /tmp 作为 Linux 上的工作目录:
<prop name="com.ibm.websphere.batch.workingDir" value="/tmp" />

未定义缺省值。

com.ibm.websphere.batch.debug
指定 truefalse 以指示命令行是否在调试方式下运行。调试方式会打印调试消息以帮助您解决阻止命令行正确运行的变量替换问题以及其他问题。
例如,启用调试方式:
<prop name="com.ibm.websphere.batch.debug" value="true" />

缺省值是 false

com.ibm.websphere.batch.expansion
指定 truefalse 以启用或禁用作业步骤属性扩展(也称为属性替换)。对于具有大量属性映射(不取决于属性扩展)的步骤,禁用此功能可提高步骤性能。
例如,禁用属性扩展:
<prop name="com.ibm.websphere.batch.expansion" value="false" />

缺省值为 true

com.ibm.websphere.batch.shell.executor
指定 Shell 执行程序命令。使用此属性将定制 Shell 指定为命令行执行程序。
例如,指定定制 Shell 为 fastshell
<prop name="com.ibm.websphere.batch.shell.executor" value="fasthell" />

缺省值是 com.ibm.websphere.batch.command.runner.shell.executor 系统属性的值。

com.ibm.websphere.batch.shell.failure.rc
指定 Shell 执行失败返回码。此返回码由 Shell 执行程序返回,用于指示无法运行指定的命令行。当 Shell 执行程序返回码与 Shell 失败返回码值相匹配时,CommandRunner 实用程序作业会将作业步骤返回码设置为 com.ibm.websphere.batch.step.failure.rc 属性的值。
例如,当指定的命令行无法运行时,Shell 将返回 -1
<prop name="com.ibm.websphere.batch.shell.failure.rc" value="-1" />

缺省值是 com.ibm.websphere.batch.command.runner.shell.failure_rc 系统属性的值。

com.ibm.websphere.batch.step.failure.rc
指定命令行未能执行时的作业步骤返回码。当 Shell 执行程序返回码与 com.ibm.websphere.batch.shell.failure.rc 的值相匹配时,将返回此作业步骤返回码。
例如,当 Shell 无法运行时,作业步骤将返回 -1
<prop name="com.ibm.websphere.batch.step.failure.rc" value="-1" />

系统属性

所有 CommandRunner 实用程序系统属性都是可选属性。
com.ibm.websphere.batch.command.runner.shell.executor
指定 com.ibm.websphere.batch.shell.executor 作业步骤属性的缺省值。

[Windows]缺省值为 cmd.exe /c

[AIX][HP-UX][Solaris][Linux][z/OS]缺省值为 sh –c

com.ibm.websphere.batch.command.runner.shell.failure_rc
指定 com.ibm.websphere.batch.shell.failure.rc 作业步骤属性的缺省值。

[Windows]缺省值为 1

[AIX][HP-UX][Solaris][Linux][z/OS]缺省值为 127

属性替换

CommandRunner 实用程序作业步骤支持扩展的属性替换。您可以使用 xJCL 替换属性、Java 系统属性和过程变量进行扩展,如以下示例所说明。
xJCL 替换属性
以下示例将 testcase.dir xJCL 替换属性取代为工作目录。
<prop name="com.ibm.websphere.batch.workingDir" value="${testcase.dir}" />
Java 系统属性
以下示例取代了 CLASSPATH 过程变量中的 user.dir Java 系统属性:
<prop name="CLASSPATH" value="${user.dir}/classes" />
过程变量
以下示例取代了 PATH 过程变量的新值中的 PATH 过程变量:
<prop name="PATH" value="/tmp:${env:PATH}" />
要点: 如果替换属性显示在系统属性列表中,那么会将替换属性视为 Java 系统属性。否则,会将其视为 xJCL 替换属性。过程变量替换由特殊语法 ${env:<variable name>} 来表示。

过程变量

替换之后,CommandRunner 实用程序会将所有作业步骤属性添加到过程的过程变量池中,指定的命令行将在该过程中运行。

指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rgrid_cmdrun
文件名:rgrid_cmdrun.html