aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Executing a BAT file using ANT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Executing a BAT file using ANT" Watch "Executing a BAT file using ANT" New topic
Author

Executing a BAT file using ANT

Pravin Durb
Greenhorn

Joined: Oct 13, 2008
Posts: 4
Hi,

I am trying to execute a .BAT file using a simple ANT script.. I have embedded this script in my Cruisecontrol script as below.

<cruisecontrol>
<property name="deploy.bat.path" value="${base.dir}\cbs_hlp\deploy.bat"/>

<schedule>
<ant anthome= "C:\ant" target="${deploy.bat.path}"/>
</schedule>

</cruisecontrol>
I am hoping that ANT file will execute the BAT file when the Cruisecontrol build happens.. I have ANT installed under C:\ant..

Any ideas?

Thanks
[ October 13, 2008: Message edited by: Pravin Durb ]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30938
    
158

Pravin,
The ant subtask of schedule sets up an ant file to be run. Since you want to run a batch file, you'll want to use the exec subtask instead.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Pravin Durb
Greenhorn

Joined: Oct 13, 2008
Posts: 4
Hi Jeanne,
I have changed the script to use <exec> instead..but I still have the same problem

<schedule interval="30">
<composite>
<exec workingdir="C:\dev\tools\cruisecontrol-2.7.2" command="deploy.bat"/>
</composite>
</schedule>

Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What are you hoping happens and what actually happens? What you have looks like it should work (assuming C:\dev\tools\cruisecontrol-2.7.2\deploy.bat exists).

What do the cruise control logs say?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Pravin Durb
Greenhorn

Joined: Oct 13, 2008
Posts: 4
Well..I am hoping that the deploy.BAT file will execute through cruise control because when I launch it from C:\dev\tools\cruisecontrol-2.7.2 it works fine..Yes, the bat file does exist in the directory

I checked the logs also, but I don't see any reference to the <exec> task being executed

Appreciate your help!

Thanks
Pravin Durb
Greenhorn

Joined: Oct 13, 2008
Posts: 4
I was able to get it to work..Thanks

<property name="deploy.bat.path" value="${base.dir}\cbs_hlp\deploy.bat"/>

<schedule interval="30">
<exec command="${deploy.bat.path}"/>
</schedule>

I had to remove <composite> for now. didn't realize that if one task fails then it won't execute the next one in line..
 
jQuery in Action, 2nd edition
 
subject: Executing a BAT file using ANT