You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Tom Elrod <te...@e2technologies.net> on 2004/03/16 07:35:22 UTC

launching bat file in new process

Hello.  I am trying to figure out a way to launch a bat file within ant 
and have it continue on with the ant build.  I have seen a few post 
regarding this, but none of the suggestions from those posts are working 
for me.  I am using ant 1.5.4 on Windows.

Here are one of the tasks I have tried, but did not work (the bat file 
process will start, but ant will wait till I actually kill the bat 
process and close the dos window).

	<exec dir="${env.J2EE_HOME}/pointbase/tools/serveroption"
          executable="cmd"
          output="pointbase.log" failonerror="true">
          <arg line="/c call start 
${env.J2EE_HOME}\pointbase\tools\serveroption\startserver.bat"/>
       </exec>

I tried all different combinations of using /c, call, and start.  Also 
created another bat file that called this one and did not work either.

Another weird occurrence it that the startserver.bat is actually just 
running the java vm (using bat file to setup env props).  So I created 
the following taks to try to run the java process with the fork 
attribute set to true, and ant will still block on this task and not 
continue processing.

      <java classname="com.pointbase.net.netServer"
            fork="true"
            failonerror="true"
            maxmemory="512m"
            >
	 <jvmarg value="-Ddatabase.home=${env.J2EE_HOME}\pointbase\databases 
-Dpointbase.ini=${env.J2EE_HOME}\pointbase\tools\serveroption\pointbase.ini"/>
          <classpath>
            <pathelement 
location="${env.J2EE_HOME}\pointbase\lib\pbembedded.jar"/>
          </classpath>
        </java>

Anyone have any ideas how I can get the process (in this case pointbase) 
started and continue on with my ant build?

Thanks.

-Tom



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: launching bat file in new process

Posted by Antoine Lévy-Lambert <an...@antbuild.com>.
Tom Elrod wrote:

> Hello.  I am trying to figure out a way to launch a bat file within 
> ant and have it continue on with the ant build.  I have seen a few 
> post regarding this, but none of the suggestions from those posts are 
> working for me.  I am using ant 1.5.4 on Windows.
>
Hi Tom,

if you can upgrade to ant 1.6.1, you can use the exec task with the 
spawn attribute set to true.

like this :

<exec executable="cmd.exe" fork="true" spawn="true">
       <arg value="/C"/>
       <arg value="mybatch.bat"/>
       <arg value=">NUL"/>
        <arg value="2>&1"/>
</exec>

Note that I have included a redirection of stderr/stdout to NUL, because 
otherwise your script might die.
The reason being that there is currently no pumping of stdout/stderr for 
spawned scripts.

Antoine

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org