Processes may behave differently on different operating systems - for instance stop doesn't always kill the process. Please see http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4109888 for additional information.
args | A string list of arguments. |
command | The command to execute. |
dir | The working directory. |
environment | An environment variable to be set before the program is executed. |
exitValue | The exit value of the process. |
name | A name, can be any text. |
newEnvironment | Create a fresh/clean environment. |
redirectStderr | Redirect the standard error stream in standard output. |
stderr | An output to where stderr of the proces will be written. |
stdin | An input stream which will act as stdin for the process. |
stdout | An output to where stdout for the process will be written. |
stop | This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops. |
stopForcibly | Forcibly stop the process on stop. |
Example 1 | A simple example. |
Example 2 | Using the existing environment with an additional environment variable. |
Example 3 | Capturing console output to a file. |
Example 4 | Capturing console output to the logger. |
Example 5 | Using the output of one process as the input of another. |
Configured By | ELEMENT |
Access | WRITE_ONLY |
Required | No. |
A string list of arguments.
Configured By | TEXT |
Access | READ_WRITE |
Required | yes, unless args are provided instead. |
The command to execute. The command is interpreted as space delimited text which may be specified over several lines. Arguments that need to include spaces must be quoted. Within quoted arguments quotes may be escaped using a backslash.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No |
The working directory.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
An environment variable to be set before the program is executed. This is a map like property.
Access | READ_ONLY |
The exit value of the process.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
A name, can be any text.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
Create a fresh/clean environment.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
Redirect the standard error stream in standard output.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
An output to where stderr of the proces will be written.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
An input stream which will act as stdin for the process.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
An output to where stdout for the process will be written.
Access | READ_ONLY |
Required | Read Only. |
This flag is set by the stop method and should be examined by any Stoppable jobs in their processing loops.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No, defaults to false. |
Forcibly stop the process on stop.
A simple example.
<exec name="Batch Example"> cmd /C "${oddjob.dir}\bin\greeting.bat" Hello </exec>Oddjob will treat arguments in quotes as single program argument and allows them to be escaped with backslash. If this is too confusing it is sometimes easier to specify the command as individual arguments. The above is equivalent to:
<exec name="Batch Example"> <args> <list> <values> <value value="cmd"/> <value value="/C"/> <value value="${oddjob.dir}\bin\greeting.bat"/> <value value="Hello"/> </values> </list> </args> </exec>
Using the existing environment with an additional environment variable.
<oddjob> <job> <exec name="Example With Environment" id="exec"> <environment> <value key="ODDJOB_FILE" value="myfile.txt"/> </environment> ${platform.set.command} </exec> </job> </oddjob>
Capturing console output to a file. The output is Oddjob's command line help.
<oddjob id="this"> <job> <exec id="exec" redirectStderr="true"> <stdout> <file file="${work.dir}/ExecOutput.log"/> </stdout> java -jar "${oddjob.test.run.jar}" -h </exec> </job> </oddjob>
Capturing console output to the logger. Note how the logger output can be defined with different log levels for stdout and sterr.
<oddjob id="this"> <job> <exec> <stdout> <logout level="INFO"/> </stdout> <stderr> <logout level="WARN"/> </stderr> java -jar ${oddjob.test.run.jar} -f Missing.xml ${logConfigArgs}/ </exec> </job> </oddjob>
Using the output of one process as the input of another. Standard input for the first process is provided by a buffer. A second buffer captures the output of that process and passess it to the second process. The output of the second process is captured and sent to the console of the parent process.
<oddjob id="this"> <job> <sequential> <jobs> <variables id="vars"> <ourBuffer> <buffer/> </ourBuffer> </variables> <exec> <stdin> <buffer>apples oranges pears </buffer> </stdin> <stdout> <value value="${vars.ourBuffer}"/> </stdout> java -jar "${oddjob.test.run.jar}" -f "${this.dir}/OddjobCat.xml" ${logConfigArgs} </exec> <exec id="exec"> <stdin> <value value="${vars.ourBuffer}"/> </stdin> <stdout> <stdout/> </stdout> java -jar "${oddjob.test.run.jar}" -f "${this.dir}/OddjobCat.xml" ${logConfigArgs} </exec> </jobs> </sequential> </job> </oddjob>