ExecPage added by Claus IbsenExec componentAvailable in Camel 2.3 The exec component can be used to execute a system command. URI formatwhere executable is the name, or file path, of the system command that will be executed. If executable name is used (e.g. exec:java), the executable must in the system path. URI options
Message headersThe supported headers are defined in org.apache.camel.component.exec.ExecBinding.
Message bodyIf the in message body, that that the Exec component receives, is convertible to java.io.InputStream, it is used to feed input of the executable via its stdin. After the execution, the message body is the result of the execution, that is org.apache.camel.components.exec.ExecResult instance containing the stdout, stderr, exit value and out file. The component supports the following ExecResult type converters for convenience:
If out file is used (the endpoint is configured with outFile, or there is ExecBinding.EXEC_COMMAND_OUT_FILE header) the converters return the content of the out file. If no out file is used, then the converters will use the stdout of the process for conversion to the target type. For example refer to the usage examples. Usage examplesExecuting word count (Linux)The example below executes wc (word count, Linux) to count the words in file /usr/share/dict/words. The word count (output) is written in the standart output stream of wc. Executing javaThe example below executes java with 2 arguments: -server and -version, provided that java is in the system path. The example below executes java in c:/temp with 3 arguments: -server, -version and the sytem property user.name. Executing Ant scriptsThe 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 the ant output to CamelExecOutFile.txt with -l. The file CamelExecOutFile.txt is used as out file with outFile=CamelExecOutFile.txt. The example assumes that ant.bat is in the system path, and that CamelExecBuildFile.xml is in the current directory. DependenciesMaven users need to add the following dependency to their pom.xml where ${camel-version} must be replaced by the actual version of Camel (2.3.0 or higher).
Change Notification Preferences
View Online
|
Add Comment
|
- [CONF] Apache Camel > Exec confluence
- [CONF] Apache Camel > Exec confluence
- [CONF] Apache Camel > Exec confluence
- [CONF] Apache Camel > Exec confluence
- [CONF] Apache Camel > Exec confluence
- [CONF] Apache Camel > Exec confluence