Solved

Executing a BAT file using ANT

Posted on 2008-10-13
7
6,727 Views
Last Modified: 2013-11-13
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>

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

 
</cruisecontrol>
0
Comment
Question by:pdurbha
  • 2
7 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 250 total points
ID: 22740371
According to the Ant documentation:

http://ant.apache.org/faq.html#batch-shell-execute

-----------------

How do I execute a batch file or shell script from Ant?

On native Unix systems, you should be able to run shell scripts directly. On systems running a Unix-type shell (for example, Cygwin on Windows) execute the (command) shell instead - cmd for batch files, sh for shell scripts - then pass the batch file or shell script (plus any arguments to the script) as a single command, using the /c or -c switch, respectively. See the above section for example <exec> tasks executing sh. For batch files, use something like:

<exec dir="." executable="cmd" os="Windows NT">
  <arg line="/c test.bat"/>
</exec>
0
 

Assisted Solution

by:sstair
sstair earned 250 total points
ID: 22887372
Actually, I think you might need to pass those as separate args:

<target name="whatever">
  <exec executable="cmd">
    <arg value="/c"/>
    <arg value="test.bat"/>
  </exec>
</target>
0
 
LVL 35

Expert Comment

by:TimYates
ID: 23097607
I feel this should be a split between me and sstair, as he is right that you have to separate out the params :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now