ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Reason" <matt.rea...@movielink.com>
Subject [solution] Need help using exec to do "ls -rt1 | tail -1"
Date Mon, 07 Apr 2003 19:28:12 GMT

Thanks to everyone for all the input.  I had no idea the pipe was
interpreted by the shell.

With that in mind, I got it to work.  Here is how to do it:

<target name="getNewest">
        <exec dir="${sourcedir}" executable="sh"
outputproperty="theNewestFile">
                <arg line="-c &quot;ls -rt1 | tail -1&quot;"/>
        </exec>
        <echo message="The newest file in ${sourcedir} is:
${theNewestFile}"/> 
</target>

NOTE: You have to put the actual command in quotes (&quot).

Matt


-----Original Message-----
From: Stefan Bodewig [mailto:bodewig@apache.org] 
Sent: Monday, April 07, 2003 12:57 AM
To: user@ant.apache.org
Subject: Re: Need help using exec to do "ls -rt1 | tail -1"


On Fri, 4 Apr 2003, Matt Reason <matt.reason@movielink.com> wrote:

> The exec task seems to hate the fact that one of my arguments is a 
> pipe.

I won't repeat that this is due to the fact that pipe's are interpreted
by the shell 8-)

> Does anyone have a workaround?

Use <exec>'s output attribute to write the result of ls to a temporary
file and read this file into a property using <loadfile> and a nested
TailFilter.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message