2

I'm trying to run the following command from an Ant build file:

sh /home/myuser/scripts/run.sh -p=8888 -z=true /home/myuser/resources/mydir

So far here's my best attempt:

<target name="run">
    <exec executable="/bin/bash">
        <arg line="/home/myuser/scripts/run.sh"/>
        <arg line="-p=8888"/>
        <arg line="-z=true"/>
        <arg line="/home/myuser/resources/mydir"/>
    </exec>
</target>

When I run this, I don't get any Ant output, except a BUILD SUCCESSFUL message. However, running this script from a terminal produces loads of output. I'm not sure if I've set up the <exec/> task correctly, or how to even begin debugging this. Thanks in advance.

Update when I run ant in verbose mode, I get the following output:

[exec] Current OS is Linux
[exec] Executing '/bin/bash' with arguments:
[exec] '/home/myuser/scripts/run.sh'
[exec] '-p=8888'
[exec] '-z=true'
[exec] '/home/myuser/resources/mydir'
[exec] 
[exec] The ' characters around the executable and arguments are
[exec] not part of the command.
[exec] Usage: <run> [options] <your dir>

So it looks like Ant is inserting single quotes around my arguments. Any way to disable this behavior?

4

1 に答える 1

3

I suggest you try running the task with Ant in verbose mode - for example by passing -v on the Ant command line. You should then see how Ant formats the above task in to a command line.

I note that the command you quote is for the Bourne shell sh, but in your exec task you are running bash - could that be a reason for the difference?

于 2013-01-31T00:30:51.613 に答える