ant-user mailing list archives

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


You would think that'd work, but it doesn't.

Trust me - I've done them both.

Ant needs to pass a string with quotes in it to the sh executable.

Matt

-----Original Message-----
From: Dominique Devienne [mailto:DDevienne@lgc.com] 
Sent: Monday, April 07, 2003 12:31 PM
To: 'Ant Users List'
Subject: RE: [solution] Need help using exec to do "ls -rt1 | tail -1"


This should also work, and the quoting's done by Ant:

<exec dir="${sourcedir}" executable="sh" ...>
  <arg value="-c"/>
  <arg value="ls -rt1 | tail -1"/>
</exec>

It's a bit easier on the eyes IMHO. --DD

-----Original Message-----
From: Matt Reason [mailto:matt.reason@movielink.com] 
Sent: Monday, April 07, 2003 2:28 PM
To: Ant Users List
Subject: [solution] Need help using exec to do "ls -rt1 | tail -1"


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

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


Mime
View raw message