/** * Copy a file from local computer to a remote computer * * @param vmIpAddress remote computer ip address * @param userName remote user * @param password remote password * @param localFile local file * @param remoteDir remote directory */ public void copyFile(String vmIpAddress, String userName, String password, String localFile, String remoteDir) { Scp scp = new Scp(); scp.setLocalFile(localFile); scp.setTodir(userName + ":" + password + "@" + vmIpAddress + ":" + remoteDir); scp.setProject(PROJECT); scp.setTrust(true); log.info("Copying {} to {} on {}", localFile, remoteDir, vmIpAddress); scp.execute(); }
scp.setFile(source.getAbsolutePath()); scp.setTodir(scpDestination); scp.execute();
private void mkdirAndCopyTo(String destination, Iterable<FileSet> sets) { if (Iterables.size(sets) == 0) { log("no content: " + destination, Project.MSG_DEBUG); return; } if (sshexec(exec("test -d " + destination).render(osFamily)) == 0) {// TODO windows log("already created: " + destination, Project.MSG_VERBOSE); return; } sshexec(exec("{md} " + destination).render(osFamily)); scp.init(); String scpDestination = getScpDir(destination); log("staging: " + scpDestination, Project.MSG_VERBOSE); for (FileSet set : sets) scp.addFileset(set); scp.setTodir(scpDestination); scp.execute(); }