You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Diane Holt <ho...@yahoo.com> on 2000/10/02 12:38:20 UTC

How to get a pipe in an

I didn't think you could get a pipe into an <exec>'d command, but it turns
out you can. The way to do it is to execute "sh", then have the <arg> be
set to a line, with "-c cmd... | cmd... etc."  Because you have to quote
the command string to 'sh -c', you need to put &quot;'s at the beginning
and end. So it ends up being, for example:

<exec executable="sh" output="buildnum.properties">
 <arg line="-c &quot;p4 changes -m1 @${p4client} | cut -d' ' -f2 |
sed -e 's/^/buildnum=/'&quot;"/>
</exec>

Not terribly portable, I know, but I also know I'll never run this stuff
on anything that doesn't have a unix-type shell. (If anyone knows an
easier/better way, though, I'd like to hear about it.)

Diane



=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/