You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by neilac333 <ne...@soteradefense.com> on 2013/01/08 21:44:44 UTC

Output File Name After Exec

I have a Camel route that starts off with an executable for which I use exec
and which produces an output file. The name of the file is specified in the
outFile parameter to Exec. What I want to do next is to pass that file
/name/--not the contents--in the message body to the next component in the
route. 

Seems simple enough, but I don't see any clues in the documentation as to
how to get that outFile name into a message body. Your insight is
appreciated.

Thanks.




--
View this message in context: http://camel.465427.n5.nabble.com/Output-File-Name-After-Exec-tp5725152.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Output File Name After Exec

Posted by Andrea Tarocchi <an...@gmail.com>.
Can you provide the non working route?


On Tue, Jan 8, 2013 at 9:44 PM, neilac333
<ne...@soteradefense.com>wrote:

> I have a Camel route that starts off with an executable for which I use
> exec
> and which produces an output file. The name of the file is specified in the
> outFile parameter to Exec. What I want to do next is to pass that file
> /name/--not the contents--in the message body to the next component in the
> route.
>
> Seems simple enough, but I don't see any clues in the documentation as to
> how to get that outFile name into a message body. Your insight is
> appreciated.
>
> Thanks.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Output-File-Name-After-Exec-tp5725152.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
"In a world without walls and fences who needs Windows and Gates?"

Re: Output File Name After Exec

Posted by Andrea Tarocchi <an...@gmail.com>.
Hi,

outFile is an option that you use to instruct the exec component on which
file is the output of the executed command;
in other words the component first execs the command then grab the outFile
specified and put it in the body;

that said, assuming ${outFilePath} is a property correctly resolved, I
would do something similar to:
from("servlet:///my-endpoint")
            .to("exec:${shellScriptPath}?outFile=${outFilePath}")
            .setBody(${outFilePath})
            .bean(new DataProvider())
            .marshal(jsonDataFormat)

Even if executing a command that produce an output in a file and discarding
that file seems odd to me.

Andrea.




On Thu, Jan 10, 2013 at 5:11 PM, neilac333 <neil.chaudhuri@soteradefense.com
> wrote:

> Thanks for your responses.
>
> To answer the first question, here is the route I have so far:
>
> from("servlet:///my-endpoint")
>             .to("exec:${shellScriptPath}?outFile=${outFilePath}")
>             .convertBodyTo(String.class)
>             .bean(new DataProvider())
>             .marshal(jsonDataFormat)
>
> What I would like to do is replace the convertBodyTo with something that
> would send ${outFilePath}--the outFile /name/--as the message body. As it
> stands now, the outFile /contents/ are the message body.
>
> As for Claus' solution, I am familiar with the transformer EIP, but I am
> not
> sure how to apply it. In other words, I am not sure how to transform
> /org.apache.camel.components.exec.ExecResult/ into a string with the
> outFile
> value.
>
> I would appreciate some clarification on what I'm missing.
>
> Thanks.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Output-File-Name-After-Exec-tp5725152p5725303.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
"In a world without walls and fences who needs Windows and Gates?"

Re: Output File Name After Exec

Posted by neilac333 <ne...@soteradefense.com>.
Thanks for your responses. 

To answer the first question, here is the route I have so far:

from("servlet:///my-endpoint")
            .to("exec:${shellScriptPath}?outFile=${outFilePath}")
            .convertBodyTo(String.class)
            .bean(new DataProvider())
            .marshal(jsonDataFormat)

What I would like to do is replace the convertBodyTo with something that
would send ${outFilePath}--the outFile /name/--as the message body. As it
stands now, the outFile /contents/ are the message body.

As for Claus' solution, I am familiar with the transformer EIP, but I am not
sure how to apply it. In other words, I am not sure how to transform
/org.apache.camel.components.exec.ExecResult/ into a string with the outFile
value.

I would appreciate some clarification on what I'm missing.

Thanks.




--
View this message in context: http://camel.465427.n5.nabble.com/Output-File-Name-After-Exec-tp5725152p5725303.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Output File Name After Exec

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 8, 2013 at 9:44 PM, neilac333
<ne...@soteradefense.com> wrote:
> I have a Camel route that starts off with an executable for which I use exec
> and which produces an output file. The name of the file is specified in the
> outFile parameter to Exec. What I want to do next is to pass that file
> /name/--not the contents--in the message body to the next component in the
> route.
>
> Seems simple enough, but I don't see any clues in the documentation as to
> how to get that outFile name into a message body. Your insight is
> appreciated.
>

See this EIP
http://camel.apache.org/message-translator.html

To set the message body with the content of a message header

<transform>
   <header>myHeader</header>
</transform>

Using the header language
http://camel.apache.org/header.html



> Thanks.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Output-File-Name-After-Exec-tp5725152.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen