Rhino wrote:

I would like to be able to run an Ant (1.6.1) script from a Windows batch file on XP. Unfortunately, my Ant script contains <input> tasks and they are messing me up.
Here is my batch file, cond3.bat:
------------------------------------
rem Batch file to run an Ant script.
rem This variable is the drive that contains the executable program.
set progdrive=d:
rem This variable sets the path to the script.
set Script=eclipse\workspace\resume\xml
rem Get into the directory containing the program.
%progdrive%
cd %Script%
rem This command runs the program.
ant -f cond3.xml
pause


So far my script works fine when run from a batch file except that the command window closes very quickly upon completion of the script and the user can't see the message generated by the 'end' target, even though I have a Windows 'pause' command at the end of the batch file. The 'pause' command works on other batch files I've written so I don't see why it doesn't in this case.


The pause command is never executed. Windows batch files are weird beasts. Control returns to them after the program they call has finished, but it does not return to them when they call another batch file. Weird, huh? Especially considering that the call syntax is the same.
ant is a batch file. Specifically, you're calling %ANT_HOME%\bin\ant.bat (or ant.cmd). Thus, execution doesn't return to your batch file after ant finishes.


The solution is to use the special call keyword, which ensures that execution returns:
call ant -f cond3.xml


Sebastian Redl

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to