GeeCON Prague 2014*
The moose likes Ant, Maven and Other Build Tools and the fly likes SCP task in Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "SCP task in Ant" Watch "SCP task in Ant" New topic
Author

SCP task in Ant

Priya Jothi
Ranch Hand

Joined: Jul 13, 2004
Posts: 168
Hi,

Im trying to copy a file from one location to another using SCP task.

<scp file="log.txt" todir="user assword@host:/log" port="21"/>



But it is not getting copied.Instead it throws connect exception.In this case source and destination are in the same machine.

Can somebody help me on this?.

Thanks in advance..

Regards,
Priya.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Originally posted by Priya Jothi:
Im trying to copy a file from one location to another using SCP task.

<scp file="log.txt" todir="user:password@host:/log" port="21"/>

Is it supposed to be localhost???

Originally posted by Priya Jothi:
In this case source and destination are in the same machine.
[/QB]

Why not use copy task?
Priya Jothi
Ranch Hand

Joined: Jul 13, 2004
Posts: 168
To start with a simple case i'm copying to a local machine.But in future i may change the host to refer to remote machine also.In that case also the same task need to be used instead of writing a new one.Thats why am using SCP instead of copy task.
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214

Copies a file or FileSet to or from a remote machine running SSH daemon. FileSet only works for copying files from the local machine to a remote machine.


So, whether it's a local or remote machine you are expected to be running a SSH daemon. You aren't running anything that is listening on socket 21 hence the "Connection Refused" error.

Even if you were running an SSH daemon, it listens by default on port 22 (not port 21), SCP != FTP


I have no java certifications. This makes me a bad programmer. Ignore my post.
Aruneesh Salhotra
Ranch Hand

Joined: May 12, 2004
Posts: 167
I see that scp works for SSH2 protocol. I had issues using scp.
Since most of our security is based on SSH1, I started using exec to invoke scp.

Check below.

<exec dir="${anthome.dir}" executable="scp" output="scpROOT.dir">
<arg line=" -oProtocol=1 -i /home/tomcat/.ssh/identity /earlierBuilds/Build_99/${treeLabel}_ROOT.war tomcat@${Machine}:/usr/local/tomcat528/webapps/ROOT.war"/>
</exec>
 
GeeCON Prague 2014
 
subject: SCP task in Ant