Abhinav Garg Abhinav Garg - 5 months ago 23
Java Question

Ant: copying a directory from one windows system to another

How to copy a directory from a windows system to a remote windows system using ant

there is one scp command and FTP command, please provide me an example to perform this task using scp and ftp.

Also scp requires SSH which is not common for windows system.

So how to use SCP on windows system using ant

Also if you know any better approach for windows system using ant or java, please share

Also there is one SC command(don't know how to use it)



<scp file="${username}:${password}@${ip}:${path-to-file}" todir="${dir}" trust="true" />

or Upload:

<scp file="${path-to-file}" todir="${username}:${password}@${ip}:${dir}" trust="true" />  

Ant scp task provides attributes such as localFile and remoteFile to replace "file", and localTofile / localTodir and remoteTofile / remoteTodir to replace "dir". Using these attributes can help avoid confusion when you need some scp tasks to get files from the server to local machine, while others to upload files from the local machine to server.
Like this (for uploading):

<scp localFile="${path-to-file}" remoteTodir="${username}:${password}@${ip}:${dir}" trust="true" />

Check the ant manual to see more information: http://ant.apache.org/manual/Tasks/scp.html

1. Avoid copying multiple files; Copy a zip archive and a ant build file together with it, and unzip on target machine.
2. Using scp, you need to setup ssh server on the target machine; you also need to put jsch.jar in your ANT_HOME/lib. The jsch.jar can be downloaded from