Created
May 11, 2014 07:27
-
-
Save michaelrice/26cd4c2fedd68b1a6a73 to your computer and use it in GitHub Desktop.
example of SCPClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String runCommandWithOutput(Connection connection) { | |
log.trace("SCP command to place ${file} on ${host} at ${remotedir}") | |
output = new StringBuilder() | |
try { | |
SCPClient scp = connection.createSCPClient() | |
scp.put(file, 0, remotedir, "0600") | |
connection.close() | |
output.append("File $file should now be copied to $host:$remotedir\n") | |
} | |
catch (Exception e) { | |
log.error("Unable to copy ${file} to ${host}:${remotedir}", e) | |
output.append(e.message) | |
} | |
return output.toString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is what I get in my logs:
I then end up with a blank file on my server
If you wanted to see the RemoteConnection file that is also being used to get the Connection it can be found here: https://github.com/michaelrice/RemoteSSH/blob/devwork/src/groovy/grails/plugin/remotessh/RemoteConnection.groovy