You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eric Fetzer <el...@yahoo.com.INVALID> on 2014/12/05 19:24:21 UTC

kicking my butt with something very simple

All,
I've tried all I can figure out to try on a simple unix command in redhat.  I can run the command line and it works fine, but ant can't run it to save its life:
<exec executable="sort" dir=".">
  <arg value="-u"/>
  <arg value="existingFile"/>
  <arg value=">"/>
  <arg value="newFile"/>
</exec>
I've tried putting all the args together, putting some of the args together...  If I run it like this, I get "sort: stat failed: >: No such file or directory.  If I put the "existingFile > newFile" in the same arg, I get "sort: stat failed existingFile > newFile: No such file or directory.  If I make the executable "bash" and use "sort" as the first argument, I get:  [exec] /bin/sort: /bin/sort: cannot execute binary file.  If I run it as bash and put all the arguments into a single arg value, I get: [exec] bash: sort -u existingFile > newFile: No such file or directory.

This has got to be simple, please help!

Thanks,
Erc

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


Re: kicking my butt with something very simple

Posted by Stefan Bodewig <bo...@apache.org>.
On 2014-12-05, Eric Fetzer wrote:

> I've tried all I can figure out to try on a simple unix command in
> redhat.  I can run the command line and it works fine, but ant can't
> run it to save its life:

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

> I've tried putting all the args together, putting some of the args
> together...  If I run it like this, I get "sort: stat failed: >: No
> such file or directory.

This is because stdout redirection is something the shell handles for
you on Unix and ant executes the command directly.

You can either use the task's output attribute to create newfile or
execute the command via the shell:

        <http://ant.apache.org/faq#shell-redirect-2>

Stefan

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


Re: kicking my butt with something very simple

Posted by Jonathan Rosenberg <jr...@tabbysplace.org>.
It looks like you're trying to redirect output (with >), yes?
Remember that redirection is done by a shell, not by the 'sort'
command.

You need to exec sh or bash, or another shell that handles >.  Or,
handle the output yourself.

Make sense?

--
Jonathan Rosenberg
Founder & Executive Director
Tabby's Place, a Cat Sanctuary
http://www.tabbysplace.org/


On Fri, Dec 5, 2014 at 1:41 PM, Eric Fetzer
<el...@yahoo.com.invalid> 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
>
> I'm using ant 1.7.1.
>
> Thanks,
> Eric
>
>
> On Friday, December 5, 2014 11:24 AM, Eric Fetzer <el...@yahoo.com.INVALID> wrote:
> All,
> I've tried all I can figure out to try on a simple unix command in redhat.  I can run the command line and it works fine, but ant can't run it to save its life:
> <exec executable="sort" dir=".">
>   <arg value="-u"/>
>   <arg value="existingFile"/>
>   <arg value=">"/>
>   <arg value="newFile"/>
> </exec>
> I've tried putting all the args together, putting some of the args together...  If I run it like this, I get "sort: stat failed: >: No such file or directory.  If I put the "existingFile > newFile" in the same arg, I get "sort: stat failed existingFile > newFile: No such file or directory.  If I make the executable "bash" and use "sort" as the first argument, I get:  [exec] /bin/sort: /bin/sort: cannot execute binary file.  If I run it as bash and put all the arguments into a single arg value, I get: [exec] bash: sort -u existingFile > newFile: No such file or directory.
>
> This has got to be simple, please help!
>
> Thanks,
> Erc
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>

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


Re: kicking my butt with something very simple

Posted by Dominique Devienne <dd...@gmail.com>.
On Fri, Dec 5, 2014 at 8:04 PM, Dominique Devienne <dd...@gmail.com>
wrote:

> 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
>

Note that sorting can be done by the FilterChain:
https://ant.apache.org/manual/Types/filterchain.html#sortfilter
So you wouldn't need to shell-out. Which is then portable to Windows, and
possibly faster (forking and redirecting from Java has overhead). --DD

PS: Hi Stefan :)

Re: kicking my butt with something very simple

Posted by Eric Fetzer <el...@yahoo.com.INVALID>.
Thanks for all of the replies!  I've got it working with:

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


 

On Friday, December 5, 2014 12:11 PM, Earl Hood <ea...@earlhood.com> wrote:
On Fri, Dec 5, 2014 at 1:04 PM, Dominique Devienne <dd...@gmail.com> wrote:


> 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.

No.  A lone '>' causes no problems.

It is good practice to escape it when a literal '>' is needed, but it is
not required.

--ewh

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

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


Re: kicking my butt with something very simple

Posted by Antoine Levy Lambert <an...@gmx.de>.
As Dominique mentioned,  you can use a nested redirector element with a nested outputfilterchain 

something like 

<exec>
   <redirector output=“myfile.log">
      <outputfilterchain>
          <sortfilter/>
      </outputfilterchain>
   </redirector>
</exec>


see http://ant.apache.org/manual/Types/redirector.html
and http://ant.apache.org/manual/Types/filterchain.html

Regards,

Antoine

On Dec 5, 2014, at 2:29 PM, Dominique Devienne <dd...@gmail.com> wrote:

> On Fri, Dec 5, 2014 at 8:09 PM, Earl Hood <ea...@earlhood.com> wrote:
> 
>> On Fri, Dec 5, 2014 at 1:04 PM, Dominique Devienne <dd...@gmail.com>
>> wrote:
>>> 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.
>> 
>> No.  A lone '>' causes no problems.
>> 
>> It is good practice to escape it when a literal '>' is needed, but it
>> is not required.
>> 
> 
> Thanks. I now see in http://www.w3.org/TR/REC-xml/#syntax that only < and &
> are required to be "escaped". --DD


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


Re: kicking my butt with something very simple

Posted by Dominique Devienne <dd...@gmail.com>.
On Fri, Dec 5, 2014 at 8:09 PM, Earl Hood <ea...@earlhood.com> wrote:

> On Fri, Dec 5, 2014 at 1:04 PM, Dominique Devienne <dd...@gmail.com>
> wrote:
> > 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.
>
> No.  A lone '>' causes no problems.
>
> It is good practice to escape it when a literal '>' is needed, but it
> is not required.
>

Thanks. I now see in http://www.w3.org/TR/REC-xml/#syntax that only < and &
are required to be "escaped". --DD

Re: kicking my butt with something very simple

Posted by Earl Hood <ea...@earlhood.com>.
On Fri, Dec 5, 2014 at 1:04 PM, Dominique Devienne <dd...@gmail.com> wrote:

> 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.

No.  A lone '>' causes no problems.

It is good practice to escape it when a literal '>' is needed, but it is
not required.

--ewh

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


Re: kicking my butt with something very simple

Posted by Dominique Devienne <dd...@gmail.com>.
On Fri, Dec 5, 2014 at 7:41 PM, Eric Fetzer <el...@yahoo.com.invalid>
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

Re: kicking my butt with something very simple

Posted by Eric Fetzer <el...@yahoo.com.INVALID>.
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

I'm using ant 1.7.1.

Thanks,
Eric
 

On Friday, December 5, 2014 11:24 AM, Eric Fetzer <el...@yahoo.com.INVALID> wrote:
All,
I've tried all I can figure out to try on a simple unix command in redhat.  I can run the command line and it works fine, but ant can't run it to save its life:
<exec executable="sort" dir=".">
  <arg value="-u"/>
  <arg value="existingFile"/>
  <arg value=">"/>
  <arg value="newFile"/>
</exec>
I've tried putting all the args together, putting some of the args together...  If I run it like this, I get "sort: stat failed: >: No such file or directory.  If I put the "existingFile > newFile" in the same arg, I get "sort: stat failed existingFile > newFile: No such file or directory.  If I make the executable "bash" and use "sort" as the first argument, I get:  [exec] /bin/sort: /bin/sort: cannot execute binary file.  If I run it as bash and put all the arguments into a single arg value, I get: [exec] bash: sort -u existingFile > newFile: No such file or directory.

This has got to be simple, please help!

Thanks,
Erc

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

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