You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "BlaineNewsletters(@yahoo)" <bl...@yahoo.com> on 2001/08/07 18:24:11 UTC

Launch a separate process(terminal window) from Ant [Linux]

I'm trying to launch a separate process from Ant (call Weblogic's startup
script, startWebLogic.sh) in a new window, and have the original window run
in parallel.
This is no problem within Win2000. I use the exec task to call "start" to
launch a new window and give it the command line parameters for
startWebLogic.cmd
When trying to use the exec task for Linux, I can't accomplish the same
thing. I've tried various different methods (xterm, sh) but without success.
I can get a new terminal launched and weblogic runs, but the originating
terminal waits for weblogic to complete before continuing.

I haven't been able to figure out a way to correctly do this and I was
hoping somebody else had. As a last resort, people have suggested I call
"java" and then use "fork" to return control back to Ant.
Any suggestions?
----------------------------------------------------------------------------
---------------------------------------------------
<!--method #1-->

<target name="start.weblogic_600" >
    <exec dir="${appsrv.home}" executable="start" os="Windows 2000,Windows
NT">
            <arg line="startWebLogic.cmd" />
            <env key="BEA_HOME" value="${bea.home}" />
    </exec>
    <exec dir="${appsrv.home}/config/mydomain" executable="/bin/sh"
os="Linux,Solaris">
            <arg line="./startWebLogic.sh " />
    </exec>
</target>
----------------------------------------------------------------------------
---------------------------------------------------
<!--method #2-->

<target name="start.weblogic_600" >
<exec dir="${appsrv.home}" executable="start" os="Windows 2000,Windows NT">
<arg line="startWebLogic.cmd" />
<env key="BEA_HOME" value="${bea.home}" />
</exec>
<exec executable="${appsrv.home}/config/mydomain/startWebLogicInXTerm.sh"
os="Linux,Solaris"/>
</target>

------------------------------Contents of
startWebLogicInXTerm.sh-----------------------------------------------------
----
#!/bin/sh
pushd /usr/local/bea/wlserver6.0/config/mydomain
xterm -e ".startWebLogic.sh" &
popd

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

Blaine Kendall, QA Developer
Everypath Canada Corp | www.everypath.com


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: Launch a separate process(terminal window) from Ant [Linux]

Posted by Matthew Inger <ma...@sedonacorp.com>.
BlaineNewsletters(@yahoo) wrote:

>I'm trying to launch a separate process from Ant (call Weblogic's startup
>script, startWebLogic.sh) in a new window, and have the original window run
>in parallel.
>This is no problem within Win2000. I use the exec task to call "start" to
>launch a new window and give it the command line parameters for
>startWebLogic.cmd
>When trying to use the exec task for Linux, I can't accomplish the same
>thing. I've tried various different methods (xterm, sh) but without success.
>I can get a new terminal launched and weblogic runs, but the originating
>terminal waits for weblogic to complete before continuing.
>
>I haven't been able to figure out a way to correctly do this and I was
>hoping somebody else had. As a last resort, people have suggested I call
>"java" and then use "fork" to return control back to Ant.
>Any suggestions?
>----------------------------------------------------------------------------
>---------------------------------------------------
><!--method #1-->
>
><target name="start.weblogic_600" >
>    <exec dir="${appsrv.home}" executable="start" os="Windows 2000,Windows
>NT">
>            <arg line="startWebLogic.cmd" />
>            <env key="BEA_HOME" value="${bea.home}" />
>    </exec>
>    <exec dir="${appsrv.home}/config/mydomain" executable="/bin/sh"
>os="Linux,Solaris">
>            <arg line="./startWebLogic.sh " />
>    </exec>
></target>
>----------------------------------------------------------------------------
>---------------------------------------------------
><!--method #2-->
>
><target name="start.weblogic_600" >
><exec dir="${appsrv.home}" executable="start" os="Windows 2000,Windows NT">
><arg line="startWebLogic.cmd" />
><env key="BEA_HOME" value="${bea.home}" />
></exec>
><exec executable="${appsrv.home}/config/mydomain/startWebLogicInXTerm.sh"
>os="Linux,Solaris"/>
></target>
>
>------------------------------Contents of
>startWebLogicInXTerm.sh-----------------------------------------------------
>----
>#!/bin/sh
>pushd /usr/local/bea/wlserver6.0/config/mydomain
>xterm -e ".startWebLogic.sh" &
>popd
>
>----------------------------------------------------------------------------
>---------------------------------------------------
>
>Blaine Kendall, QA Developer
>Everypath Canada Corp | www.everypath.com
>
>
>_________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>
PS:   you could write a task which spawned your process through
java.lang.Runtime.exec() in a seperate thread.  So what would happen
is your task would spawn the thread, and return control to ant, thereby
running your process in the background.


-- 
Matt Inger (matt.inger@sedonacorp.com)
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
 as yet, is suspicious." -H.L. Mencken 




Re: Launch a separate process(terminal window) from Ant [Linux]

Posted by Matthew Inger <ma...@sedonacorp.com>.
BlaineNewsletters(@yahoo) wrote:

>I'm trying to launch a separate process from Ant (call Weblogic's startup
>script, startWebLogic.sh) in a new window, and have the original window run
>in parallel.
>This is no problem within Win2000. I use the exec task to call "start" to
>launch a new window and give it the command line parameters for
>startWebLogic.cmd
>When trying to use the exec task for Linux, I can't accomplish the same
>thing. I've tried various different methods (xterm, sh) but without success.
>I can get a new terminal launched and weblogic runs, but the originating
>terminal waits for weblogic to complete before continuing.
>
>I haven't been able to figure out a way to correctly do this and I was
>hoping somebody else had. As a last resort, people have suggested I call
>"java" and then use "fork" to return control back to Ant.
>Any suggestions?
>----------------------------------------------------------------------------
>---------------------------------------------------
><!--method #1-->
>
><target name="start.weblogic_600" >
>    <exec dir="${appsrv.home}" executable="start" os="Windows 2000,Windows
>NT">
>            <arg line="startWebLogic.cmd" />
>            <env key="BEA_HOME" value="${bea.home}" />
>    </exec>
>    <exec dir="${appsrv.home}/config/mydomain" executable="/bin/sh"
>os="Linux,Solaris">
>            <arg line="./startWebLogic.sh " />
>    </exec>
></target>
>----------------------------------------------------------------------------
>---------------------------------------------------
><!--method #2-->
>
><target name="start.weblogic_600" >
><exec dir="${appsrv.home}" executable="start" os="Windows 2000,Windows NT">
><arg line="startWebLogic.cmd" />
><env key="BEA_HOME" value="${bea.home}" />
></exec>
><exec executable="${appsrv.home}/config/mydomain/startWebLogicInXTerm.sh"
>os="Linux,Solaris"/>
></target>
>
>------------------------------Contents of
>startWebLogicInXTerm.sh-----------------------------------------------------
>----
>#!/bin/sh
>pushd /usr/local/bea/wlserver6.0/config/mydomain
>xterm -e ".startWebLogic.sh" &
>popd
>
>----------------------------------------------------------------------------
>---------------------------------------------------
>
>Blaine Kendall, QA Developer
>Everypath Canada Corp | www.everypath.com
>
>
>_________________________________________________________
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>
exec always waits for the process to finish it seems. on window2000, the 
start task
spawns another process and then finishes, which is why you see control 
return to the
command prompt.  On unix, this is built in using the '&' character. 
 However, the
requested process is still running, so ant will wait for it.  what you 
really need is
some sort of wrapper that will create an os process which spawns the 
desired one
in the background, and exits, without killing it's child processes.


-- 
Matt Inger (matt.inger@sedonacorp.com)
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
 as yet, is suspicious." -H.L. Mencken