ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <>
Subject Re: ant exec task: ssh username contains spaces, how to escape?
Date Fri, 04 Feb 2011 14:30:12 GMT
Hello Stein Inge,

I am sure that ant does a good at keeping together a command line 
argument defined with <arg value=" "/>

In fact I have even checked this assertion on Windows/Cygwin

- build.xml

<project name="testspaceinarg">
<exec executable="bash" failonerror="true">
<arg value="./" />
<arg value="-tt" />
<arg value="stein inge morisbak@localhost" />
<arg value="if [ -f /tmp/test.txt ]; then rm -f /tmp/test.txt ; fi" />

- contents of

for arg in "$@" ; do
         i=$(( $i + 1 ))
     echo $i " argument : " $arg " END"

- output

Buildfile: C:\dev\build.xml

      [exec] 1  argument :  -tt  END
      [exec] 2  argument :  stein inge morisbak@localhost  END
      [exec] 3  argument :  if [ -f /tmp/test.txt ]; then rm -f 
/tmp/test.txt ; fi  END

Total time: 0 seconds

Can you test the same on your Mac ?

If it behaves the same as what I am showing, it would mean that the ssh 
command line client does not support user name argument when it is 
splitted by spaces.



On 2/2/2011 3:44 AM, Stein Inge Morisbak wrote:
> That's what I thought also, but in practice it doesn't work, at least not on my machine
(mac os x)
> I know about the sshexec task, but the problem with this task is that it is not possible
to give options to the ssh command. I left that out in my example, but I need to give the
'-tt' option to ssh. Like this:
> <exec executable="ssh" failonerror="true">
>       <arg value="-tt" />
>     <arg value="stein inge morisbak@localhost" />
>     <arg value="if [ -f /tmp/test.txt ]; then rm -f /tmp/test.txt ; fi" />
> </exec>
> Regards,
> Stein Inge

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message