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?

1
  • 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? Commented Jan 31, 2013 at 1:04

1 Answer 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?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @martin clayton (+1) - please see my updates above, and thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.