This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant exec task -- unable to execute a command

 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic