File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes run two <exec> task in the same command shell 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 "run two <exec> task in the same command shell" Watch "run two <exec> task in the same command shell" New topic

run two <exec> task in the same command shell

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
the two executable file, one is called "setENV.cmd", the other is called "doThings.exe".
in the windows command console, the "setENV.cmd" is used to setup the environment, and it must be run first, then the "doThings.exe" can be run. or not, "doThings.exe" can't work. the manual operation works well, because we can type the two commands within the SAME command console.
but while i run them in the ant script by exec task, there is problem., the build.xml snippet is as follow:

<target name="deploy">
<exec executable="setENV.cmd" />
<exec executable="doThings.exe">
<arg value="......" />
<arg value="......" />

while i execute the target, i am sure the "setENV.cmd" is run well, but the "doThings.exe" can't work well,
that means the two exec tasks are not run within the same command shell, who can tell me how to config the ant to run the two exec tasks within the same shell?

Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Hi there,

Why don't you execute the exe as the last command in your CMD script?

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Or create another CMD file that runs the CMD file and EXE file (if you cannot, or do not want to, change the setenv.cmd file).

JBoss In Action
I agree. Here's the link:
subject: run two <exec> task in the same command shell
It's not a secret anymore!