You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Ken Wood <kw...@i2.com> on 2000/09/05 23:29:04 UTC
Exec arguments, pipes, and I/O redirection...
I guess I'm confused.
I'm doing
<exec executable="cat"
dir=".">
<arg line="etc/jsm.properties | sed -f
tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
</exec>
Ant DOES 'cat etc/jsm.properties" but it barfs on the rest, because
it apparently wants to interpret every token on the arg list as files:
[exec] cat: cannot open |
[exec] cat: cannot open sed
[exec] cat: cannot open -f
[exec] cat: cannot open >
This example is trivial, but more generally it is quite common on Unix
to execute a command and pipe the output through one or more programs,
and
sometimes redirect the output. In this case, we are creating a new
file from a template using some regular expression pattern matching
and replacements....
How do I uses pipes and IO re-direction in an 'exec' ???
Re: Exec arguments, pipes, and I/O redirection...
Posted by Ken Wood <kw...@i2.com>.
Well, I naively assumed that whatever command line was created, pipes
and redirection and all,
was passed to the OS for processing... but, be that as it may,
I tried the suggestion you and Jose made. It works, I'm happy,
thanks!!
Stefan Bodewig wrote:
>
> >>>>> "KW" == Ken Wood <kw...@i2.com> writes:
>
> KW> <exec executable="cat" dir=".">
> KW> <arg line="etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
> KW> </exec>
>
> well, | sed ... is not really an arg to cat, is it? I haven't tried it
> but I think
>
> <exec executable="sh" dir=".">
> <arg value="-c" />
> <arg value="cat etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
> </exec>
Re: Exec arguments, pipes, and I/O redirection...
Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "KW" == Ken Wood <kw...@i2.com> writes:
KW> <exec executable="cat" dir=".">
KW> <arg line="etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
KW> </exec>
well, | sed ... is not really an arg to cat, is it? I haven't tried it
but I think
<exec executable="sh" dir=".">
<arg value="-c" />
<arg value="cat etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
</exec>
should work.
Stefan