tags:

views:

68

answers:

2

Please take a look at this line:

${server_username}:${server_password}@@{server}:/tmp

The double @@ causes problems. Instead of user:pass@server it displays as user:passserver and therefore is unable to connect to the remote ssh server.

How do you tell ant to leave the @ be?

This is my code:

<for list="${externalLibs}" param="library"> 
  <sequential>
    <for list="${servers}" param="server"> 
      <sequential>
        <echo> Copying @{library} to @{server} ${server_username}:${server_password}@@@{server}:/tmp/@{library}/${@{library}}/ 
        </echo>
        <scp todir="${server_username}:${server_password}@@@{server}:/tmp/@{library}/${@{library}}/">     
          <fileset dir="/tmp/@{library}/${@{library}}/" /> 
        </scp>
      </sequential> 
    </for>
  </sequential> 
</for>

In the echo command, it shows like this:

Copying LibraryName to myserver.domain.com username:password@{server}:/tmp/LibraryName/LibraryBar

+1  A: 

It seems that it is a typo in that line - second last @ should be changed to $: ${server_username}:${server_password}@${server}:/tmp

ZloiAdun
Also I am assuming that you are using the Ant SCP task
ZloiAdun
Sorry Zloi, forgot to mention that the command is enclosed in a for loop.
Steve Griff
Then you should use triple @ as recomended by Alexander Pogrebnyak
ZloiAdun
Cannot comment answers from others because of low reputation yet :)It works for me:<for list="server1, server2" param="server"> <sequential> <echo>${server_username}:${server_password}@@@{server}:/tmp</echo> <scp file="pom.xml" todir="${server_username}:${server_password}@@@{server}:/tmp" trust="true"/> </sequential> </for>
ZloiAdun
+1  A: 

You escape @ by doubling it, as in @@.

So in your case it will be:

${server_username}:${server_password}@@@{server}:/tmp

BTW, same rule goes for $ escape, $$ just prints a $.

In reply to OP's comment

Example:

<property name="server_username" value="user-name"/>
<property name="server_password" value="passwd"/>

<for list="s1.foo.bar,s2.foo.bar,s3.foo.bar" param="server">
  <sequential>
    <echo message="${server_username}:${server_password}@@@{server}:/tmp"/>
  </sequential>
</ac>

This produces:

 [echo] user-name:[email protected]:/tmp
 [echo] user-name:[email protected]:/tmp
 [echo] user-name:[email protected]:/tmp

So, your problem is somewhere else, probably in the loop setup code

Alexander Pogrebnyak
Hi Alexander, it doesn't seem to work for me :-( It just echo's out @{server}
Steve Griff
@Steve. Post you whole loop setup, because the example here does work.
Alexander Pogrebnyak