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?

IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
  • The single quotes are inserted in the log message so you can 'see' whitespace, they are not actually included in the command run (that's what the 'not part of the command' message is trying to say). What happens if you use /bin/sh instead of /bin/bash? – martin clayton Jan 31 '13 at 01:04

1 Answers1

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?

martin clayton
  • 76,436
  • 32
  • 213
  • 198