where ${camel-version} must be replaced by the actual versi=
on of Camel (2.3.0 or higher).

=20

URI format

=20

=20

exec://executable[?options]

=20

=20

where executable is the name, or file path, of the system c=
ommand that will be executed. If executable name is used (e.g. exec:j=
ava), the executable must in the system path.

=20

URI options

=20

=20

=20

=20

Name

=20

Default value

=20

Description

=20

=20

=20

args

=20

null

=20

The arguments of the executable. The argumen=
ts may be one or many whitespace-separated tokens, that can be quoted w=
ith " - e.g. args=3D"arg 1" arg2 will use two arg=
uments arg 1 and arg2. To include the quotes use =
"" - e.g. args=3D""arg 1"" arg2 will use the argu=
ments "arg 1" and arg2.

=20

=20

=20

workingDir

=20

null

=20

The directory in which the command should be =
executed. If null, the working directory of the current proces=
s will be used.

=20

=20

=20

timeout

=20

Long.MAX_VALUE

=20

The timeout, in milliseconds, after which the=
executable should be terminated. If execution has not completed within the=
timeout, the component will send a termination request.

=20

=20

=20

outFile

=20

null

=20

The name of a file, created by the executable=
, that should be considered as its output. If no outFile is se=
t, the standard output (stdout) of the executable will be used instead.

=20

=20

=20

binding

=20

a DefaultExecBinding instance <=
/p>

=20

A reference to a org.apache.commons.ex=
ec.ExecBinding in the Registry.

=20

=20

=20

commandExecutor

=20

a DefaultCommandExecutor instanc=
e

=20

A reference to a org.apache.commons.ex=
ec.ExecCommandExecutor in the Registry that cust=
omizes the command execution. The default command executor utilizes the commons-exec library, which adds a shutdown hook for every execu=
ted command.

=20

=20

=20

useStderrOnEmptyStdout

=20

false

=20

A boolean indicating that when stdout<=
/code> is empty, this component will populate the Camel Message Body with <=
code>stderr. This behavior is disabled (false) by defau=
lt.

=20

=20

=20

=20

Message headers

=20

The supported headers are defined in org.apache.camel.component.ex=
ec.ExecBinding.

=20

=20

=20

=20

Name

=20

Type

=20

Message

=20

Description

=20

=20

=20

ExecBinding.EXEC_COMMAND_EXECUTABLE

=20

String

=20

in

=20

The name of the system command that will be =
executed. Overrides executable in the URI.

=20

=20

=20

ExecBinding.EXEC_COMMAND_ARGS

=20

java.util.List<String>

=

=20

in

=20

Command-line arguments to pass to the execute=
d process. The arguments are used literally - no quoting is applied. Overri=
des any existing args in the URI.

=20

=20

=20

ExecBinding.EXEC_COMMAND_ARGS

=20

String

=20

in

=20

Camel 2.5: The arguments of=
the executable as a Single string where each argument is whitespace separa=
ted (see args in URI option). The arguments are used literally=
, no quoting is applied. Overrides any existing args in the UR=
I.

=20

=20

=20

ExecBinding.EXEC_COMMAND_OUT_FILE

=20

String

=20

in

=20

The name of a file, created by the executable=
, that should be considered as its output. Overrides any existing out=
File in the URI.

=20

=20

=20

ExecBinding.EXEC_COMMAND_TIMEOUT=

=20

long

=20

in

=20

The timeout, in milliseconds, after which the=
executable should be terminated. Overrides any existing timeout in the URI.

=20

=20

=20

ExecBinding.EXEC_COMMAND_WORKING_DIR

=20

String

=20

in

=20

The directory in which the command should be =
executed. Overrides any existing workingDir in the URI.

=20

=20

=20

ExecBinding.EXEC_EXIT_VALUE

<=
/td>=20

int

=20

out

=20

The value of this header is the exit valu=
e of the executable. Non-zero exit values typically indicate abnormal =
termination. Note that the exit value is OS-dependent.

=20

=20

=20

ExecBinding.EXEC_STDERR

=
=20

java.io.InputStream

=20

out

=20

The value of this header points to the standa=
rd error stream (stderr) of the executable. If no stderr is written, the va=
lue is null.

=20

=20

=20

ExecBinding.EXEC_USE_STDERR_ON_EMPTY_ST=
DOUT

=20

boolean

=20

in

=20

Indicates that when stdout is e=
mpty, this component will populate the Camel Message Body with stderr=
. This behavior is disabled (false) by default.

=20

=20

=20

=20

Message body

=20

If the Exec component receives an in message b=
ody that is convertible to java.io.InputStream, it is used to =
feed input to the executable via its stdin. After execution, the message body is the result of the execution,- that is, an o=
rg.apache.camel.components.exec.ExecResult instance containing the s=
tdout, stderr, exit value, and out file. This component supports the follow=
ing ExecResulttype converters for c=
onvenience:

=20

=20

=20

=20

From

=20

To

=20

=20

=20

ExecResult

=20

java.io.InputStream

=20

=20

=20

ExecResult

=20

String

=20

=20

=20

ExecResult

=20

byte []

=20

=20

=20

ExecResult

=20

org.w3c.dom.Document

=
=20

=20

=20

If an out file is specified (in the endpoint via outFile or=
the message headers via ExecBinding.EXEC_COMMAND_OUT_FILE), c=
onverters will return the content of the out file. If no out file is used, =
then this component will convert the stdout of the process to the target ty=
pe. For more details, please refer to the usage exa=
mples below.

=20

=20

Usage examples

=20

Executing word count (Linux)

=
=20

The example below executes wc (word count, Linux) to count =
the words in file /usr/share/dict/words. The word count (outpu=
t) is written to the standard output stream of wc.

Executing Ant scripts

=20

The following example executes Apache Ant (Windows only) with the =
build file CamelExecBuildFile.xml, provided that ant.bat=
is in the system path, and that CamelExecBuildFile.xml=
is in the current directory.

In the next example, the ant.bat command redirects its outp=
ut to CamelExecOutFile.txt with -l. The file CamelExecOutFile.txt is used as the out file with outFile=3D=
CamelExecOutFile.txt. The example assumes that ant.bat =
is in the system path, and that CamelExecBuildFile.xml is in t=
he current directory.