class Synqa::ExternalSshScp
SSH/SCP using external commands, such as “plink” and “pscp”
Attributes
scpCommandString[R]
The SCP command as a string
scpProgram[R]
The SCP client, e.g. [“scp”] or [“pscp”,“-pw”,“mysecretpassword”] (i.e. command + args as an array)
shell[R]
The SSH client, e.g. [“ssh”] or [“plink”,“-pw”,“mysecretpassword”] (i.e. command + args as an array)
Public Class Methods
new(shell, scpProgram)
click to toggle source
# File lib/synqa.rb, line 293 def initialize(shell, scpProgram) @shell = shell.is_a?(String) ? [shell] : shell @scpProgram = scpProgram.is_a?(String) ? [scpProgram] : scpProgram @scpCommandString = @scpProgram.join(" ") end
Public Instance Methods
copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun)
click to toggle source
copy a local file to a remote directory (if dryRun is false)
# File lib/synqa.rb, line 318 def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) executeCommand("#{@scpCommandString} #{sourcePath} #{userAtHost}:#{destinationPath}", dryRun) end
copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun)
click to toggle source
copy a local directory to a remote directory (if dryRun is false)
# File lib/synqa.rb, line 313 def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) executeCommand("#{@scpCommandString} -r #{sourcePath} #{userAtHost}:#{destinationPath}", dryRun) end
ssh(commandString, dryRun) { |chomp| ... }
click to toggle source
execute command on remote host (if dryRun is false), yielding lines of output
# File lib/synqa.rb, line 300 def ssh(commandString, dryRun) puts "SSH #{userAtHost} (#{shell.join(" ")}): executing #{commandString}" if not dryRun output = getCommandOutput(shell + [userAtHost, commandString]) while (line = output.gets) yield line.chomp end output.close() checkProcessStatus("SSH #{userAtHost} #{commandString}") end end