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:42:08 GMT

My bad, you are right.  I didn't see that you had swapped 'line' for
'value'.  It definitely works with 'value' and it does look better.  I
feel smarter now.

I went back to the documentation to see if I had missed something and
where I missed it (otherwise this would be a rant about undocumented
features) and I found this:

"It is highly recommended to avoid the line version when possible. Ant
will try to split the command line in a way similar to what a (Unix)
shell would do, but may create something that is very different from
what you expect under some circumstances."

Thanks again.

Matt


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


I'm surprised... the 'value' attribute quotes it's value if it contains
any spaces, and if you say it doesn't, it's a bug. Are you sure you
didn't try it with the 'line' attribute, as your example showed? These
two attributes behave differently. Running with the -verbose (or -debug)
flag will show the actual command executed. It should work as I wrote it
(I think!) --DD

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



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