wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Executing DOS commands through ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Executing DOS commands through ANT" Watch "Executing DOS commands through ANT" New topic
Author

Executing DOS commands through ANT

Pranjal Nagar
Greenhorn

Joined: Mar 23, 2010
Posts: 6
I want to execute some DOS commands through ANT. I am finding it difficult to execute commands like this in ANT:
FOR /F %%i IN ('cd') DO set DRIVE=%%~di
Any suggestion on how I can run this through ANT?


Any help is appreciated.
Karl Heinz Marbaise
Greenhorn

Joined: Aug 12, 2007
Posts: 19
Hi,

have you called it via "cmd" ? Cause those commands are part of the cmd ....

Kind regards
Karl Heinz Marbaise


Software Configuration Management (Subversion, CVS, SVK etc.) http://www.skmwiki.de/
Subversion Repository Search Engine http://www.supose.org/
Pranjal Nagar
Greenhorn

Joined: Mar 23, 2010
Posts: 6
I was earlier executing this command through a batch file(.bat) on Windows. I would now like to execute these commands through ANT.
Pranjal Nagar
Greenhorn

Joined: Mar 23, 2010
Posts: 6
Yes,
I called the comand via cmd:
<exec executable="cmd">
<arg value="FOR /F %%i IN ('cd') DO set PATH=%%~di"/>
</exec>

the PATH variable is not set to the drive letter as desired.

Can anyone tell me if I am executing this command correctly through ANT?
Pranjal Nagar
Greenhorn

Joined: Mar 23, 2010
Posts: 6
This does the trick for the above command:
<exec executable="cmd" outputproperty="PATH" >
<arg value="/c"/>
<arg value="for"/>
<arg value="/F"/>
<arg value="%i"/>
<arg value="IN"/>
<arg value="('cd')"/>
<arg value="DO"/>
<arg value="@echo"/><arg value="%~di"/>
</exec>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing DOS commands through ANT
 
Similar Threads
DOS command in java program question..
Can i Run Dos Command?
need to undeploy and stop server on sun app server
Java code to compile and run another java program
run dos cammand in java code