• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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>
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic