ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: Need help using exec to do "ls -rt1 | tail -1"
Date Fri, 04 Apr 2003 21:55:55 GMT
The problem with pipes is that they are part of the
shell command.  One thing you might try is to make
your executable a shell, with ls et al as arguments. 
Also, you could try the shell script task, pretty much
the same idea.  Or, you could send the exec output to
a file, then load it into a property using <loadfile>
with a nested filterchain consisting of a tail filter
with lines=1.

-Matt


--- Matt Reason <matt.reason@movielink.com> wrote:
> 
> That command returns the name of the newest file in
> the directory.  I
> want to put that string into a property.
> 
> The exec task seems to hate the fact that one of my
> arguments is a pipe.
> 
> Does anyone have a workaround?
> 
> I think I've tried every possible permutation of
> this:
> 
> <target name="getNewest">
>         <exec dir="${sourcedir}" executable="ls"
> outputproperty="theNewestFile">
>                 <!--
>                 <arg line="-rt1 | tail -1"/>
>                 -->                        
>                 <arg line="-rt1"/>
>                 <arg line="|"/>
>                 <arg line="tail"/>
>                 <arg line="-1"/>
>         </exec>
>         <echo message="The newest file in
> ${sourcedir} is:
> ${theNewestFile}"/>
> </target>
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

Mime
View raw message