Re: <exec> kicking my butt with something very simple

Dominique Devienne <[email protected]>
Newsgroups gmane.comp.jakarta.ant.user
Message-ID <CAFCRh--GTxNeVy3S=etBMg=1i594UhzXcttrviRaddiHEbHqSg@mail.gmail.com>
On Fri, Dec 5, 2014 at 7:41 PM, Eric Fetzer <[email protected]>
wrote:
>
> Note that I also tried:
> <exec executable="sort" dir=".">
>   <arg value="-u"/>
>   <arg file="existingFile"/>
>   <arg value=">"/>
>   <arg file="newFile"/>
> </exec>
>
> Which produced:  sort: stat failed: >: No such file or directory

Strange, I'd have thought the XML parser would choke before you even got to
running something. > is one of those reserved characters in XML, that must
be replaced with a "character entity", "&gt;" (w/o the quotes) in this case.

Beside the above, you are confusing <exec> for a shell :). "cmd args files
> out" is something the shell (sh, ksh, csh, tcsh, bash, zsh, etc...)
interprets (i.e. parses), i.e. it runs "cmd args file" and redirects the
output of that to a file calls "out".

If you look at https://ant.apache.org/manual/Tasks/exec.html, you'll see
<exec> supports an 'output' attribute for the "Name of a file to which to
write the output". So you likely want something like:

<exec executable="sort" dir="." output="newFile">
  <arg value="-u"/>
  <arg file="existingFile"/>
</exec>

There's also a more powerful way to redirect/filter/etc... using
https://ant.apache.org/manual/Types/redirector.html but the above should do
I think. --DD
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.