aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant exec task -- unable to execute a command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant exec task -- unable to execute a command" Watch "Ant exec task -- unable to execute a command" New topic
Author

Ant exec task -- unable to execute a command

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
As part of a build/deploy I want to perform a dos2unix on all files of a subdirectory.

The command I would run from the command line is

In my build.xml I have tried using



This didn't work, and it's unclear from the documentation how I would get this command to work using the exec task's executable attribute with nested arg elements.

Can anyone comment on how this would work, or if it's even possible? Perhaps I should put the commands I want to run into a script and just call that script from the exec task?

Thanks in advance for any help!


--James
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I ended up putting the dos2unix commands in a shell script file and now I call that script from within the ant task, it works fine.

--James
Eraticus Major
Greenhorn

Joined: Jul 27, 2006
Posts: 1
If you separate your executable from its arguments, using exec will work. As an example,

This target will work:

<exec executable="find">
<arg line=". -name *.xml -print" ></arg>
</exec>

This won't work, because ant will expect to find a command called "find . -name ..." instead of just "find":

<exec executable="find . -name *.xml -print" >
</exec>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant exec task -- unable to execute a command