• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Executing DOS commands through ANT

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic