ant scp task hangs on Linux
I ran into a problem where an ant scp task hangs during a fileset copy. The task is:
<scp file="${usr}:${pwd}@${hst}:${dir}/*" todir="${to}" trust="true"/>
It copies a number of files successfully and then hangs.
Note that the host that it's cop开发者_运维百科ying from is localhost, but this should make no difference.
I've also used the same ant script to copy files from the same Linux host to a windows machine, and this works without any problems.
Google search reveals that there was a similar problem in around 2007, http://www.symphonious.net/2007/10/23/ant-scpssh-task-hangs-or-never-disconnects/, but the solution of upgrading to latest version of ant (or downgrading jsch) they give doesn't fix the problem for me. (This defect is also metioned in https://issues.apache.org/bugzilla/show_bug.cgi?id=41090)
I've used ANT 1.8.2, ANT 1.7.1 and ANT 1.6.5 and they all have this problem. I'm using jsch 0.1.44, but even with a later version of jsch I get this problem.
Any ideas?
Found a workaround that solves my problem. It's to use sftp="true" attribute of the scp task, like this:
<scp file="${usr}:${pwd}@${hst}:${dir}/*" todir="${to}" trust="true" sftp="true"/>
When I used the option sftp="true" from with a maven-antrun-plugin, I was getting the following error. [ERROR] around Ant part ...... @: The type doesn't support the "sftp" attribute.
I was able to get this working by switching back to older version of jsch, specifically 0.1.29
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
</dependency>
精彩评论