Solved

Executing a BAT file using ANT

Posted on 2008-10-13
7
6,872 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

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 and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to count occurrences of each item in an array.

688 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