tags:

views:

393

answers:

2

I am trying to copy a file to a remote server using scp task in Nant.Contrib .

I have used the following code to do that:

<target name= "QADeploy"description="gthtyb" >
<loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />
<echo message="htyh"/>
<scp file="D:\SourceTest\redist.txt" server="\\10.4.30.19" user="xxx:uuuu">      
</scp>
</target>

But I am getting an error: scp failed to start. The system cannot find the file specified. The code is as follows: Then I have downloaded pscp.exe and modified the code as below:

<target name= "QADeploy"
    description="gthtyb" >
 <loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />

<echo message="htyh"/>

<scp file="D:\SourceTest\redist.txt" server="\\10.4.30.19" user="xxx:uuuu" program="C:\pscp\pscp.exe">      
</scp>

Now I am getting the following error:

[scp] ssh_init:host does not exist

External Program Failed:C:\pscp\pscp.exe

can u please help whats the best way to copy a file to a remote server using Nant. I am using this code to deploy files to a remote server.

Thanks

+1  A: 

You don't have to put two backslashes behind the IP of your server.

<scp file="D:\SourceTest\redist.txt" server="10.4.30.19" user="xxx:uuuu" program="C:\pscp\pscp.exe">

Also note that without the "path" parameter, the default destination folder is "~".

Update: it is the username that is crashing the pscp.exe program. Remove the ":" from your username or try with a different one.

Laurent Etiemble
I have tried without the baclslashes too... :)
Mini
Can you try by using "/" for your program path ?Or set the "program-path-sep" parameter to "\" ?
Laurent Etiemble
Can you also launch with the "-v+" option to turn debug output ?Can you also try to launch pcsp on the command line ?
Laurent Etiemble
Tough luck :(. still the same error Laurent.
Mini
when I tried to launch pscp and copy the file using command line I am getting the error: ssh_init:host does not exist
Mini
Is there any other way of transferring files to remote server in Nant script. Any help will be highly appreciated. Why is scp not working directly from Nant.contrib.Tasks.dll
Mini
I have updated the answer.
Laurent Etiemble
A: 

it seems like there is some weirdness on how pscp parses paths in windows. The following should fix ssh_init:host does not exist problem:

-upload
pscp some.file user@[remote-host-or-ip]:/some/path/

-download
pscp user@[remote-host-or-ip]:/some/path/some.file  some.file
ledion