1。现在可以利用下面的方法移动文件,但是当没有文件夹的时候会报错,不知道如何解决。
public static void scpPut(String host, String username, String password,
String localFile, String remoteDir) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("spc [" + localFile + "] to " + host + remoteDir);
}
Connection conn = getOpenedConnection(host, username, password);
SCPClient client = new SCPClient(conn);
client.put(localFile, remoteDir);
conn.close();
}
但是我调用 scpPut() 这个方法,如果是路径正确的话就可以COPY过去
如果是没有文件夹的话就会报错误。
Error during SCP transfer.
at ch.ethz.ssh2.SCPClient.put(SCPClient.java:575)
at ch.ethz.ssh2.SCPClient.put(SCPClient.java:533)
at ch.ethz.ssh2.SCPClient.put(SCPClient.java:394)
at jp.co.u_can.manabi.imp.batch.DeliveryInstructionBatch.scpPut(DeliveryInstructionBatch.java:444)
at jp.co.u_can.manabi.imp.batch.DeliveryInstructionBatch.execute(DeliveryInstructionBatch.java:366)
at jp.co.u_can.manabi.imp.batch.DeliveryInstructionBatch.main(DeliveryInstructionBatch.java:241)
Caused by: java.io.IOException: Remote scp terminated with error (scp: /usr/gms/20100915/0002/lst: No such file or directory).
at ch.ethz.ssh2.SCPClient.readResponse(SCPClient.java:59)
at ch.ethz.ssh2.SCPClient.sendFiles(SCPClient.java:163)
at ch.ethz.ssh2.SCPClient.put(SCPClient.java:571)
... 5 more
作者: guofc_presoft
发布时间: 2010-09-20