Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executing DOS commands through ANT

 
Pranjal Nagar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Kind regards
Karl Heinz Marbaise
 
Pranjal Nagar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic