ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <>
Subject Re: Using exec to run scripts in background
Date Wed, 14 Mar 2001 14:19:58 GMT
Hello Jesus,

Jesus Sanchez Gonzalez wrote:
>   Is there any way to use the exec tag to run a script in background?

No, not currently.  

>   What I would like to do is to start the application launching a script
> in background from ant but without having to write a new script with the
> ampersand at the end of the call.

Since you're referring to UNIX, you can try modifying the bin/antRun
script something like the following (untested):

#! /bin/sh

# Args: DIR command
cd "$1"

if [ "$BACKGROUND" = "true" ]; then
    # If no output is specified, use exec.out in the execution directory
    # Exec specifying stdin, stdout and stderr so Ant can't hang on to
    exec $CMD "$@" </dev/null > "$OUTPUT" 2>&1 &
    exec $CMD "$@"

Then in your <exec> task you would specify background execution as
    <exec executable="myapp" dir="some-dir">
        <env key="BACKGROUND" value="true" />
        <env key="OUTPUT" value="myapp.out" />  <!-- name of output file

If you don't want to modify the antRun script itself, you could create a
generic helper script along the same line and specify that as the
executable attribute to <exec> with your application executable as the
first argument.

Hope this works for you.  

About a month before Ant 1.3 was released, I came up with a patch to allow
background execution.  I was hoping to rework it for the released 1.3 but
other responsibilities have prevented me from doing so thus far.  I'll see
what I can do within the next week or so.  However, even if the committers
accept it, you would have to obtain a nightly build to pick it up.


View raw message