Class: Synqa::ExternalSshScp
- Inherits:
-
BaseSshScp
- Object
- BaseSshScp
- Synqa::ExternalSshScp
- Defined in:
- lib/synqa.rb
Overview
SSH/SCP using external commands, such as “plink” and “pscp”
Instance Attribute Summary collapse
-
#scpCommandString ⇒ Object
readonly
The SCP command as a string.
-
#scpProgram ⇒ Object
readonly
The SCP client, e.g.
-
#shell ⇒ Object
readonly
The SSH client, e.g.
Attributes inherited from BaseSshScp
Instance Method Summary collapse
-
#copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) ⇒ Object
copy a local file to a remote directory (if dryRun is false).
-
#copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) ⇒ Object
copy a local directory to a remote directory (if dryRun is false).
-
#initialize(shell, scpProgram) ⇒ ExternalSshScp
constructor
A new instance of ExternalSshScp.
-
#ssh(commandString, dryRun) ⇒ Object
execute command on remote host (if dryRun is false), yielding lines of output.
Methods inherited from BaseSshScp
#close, #deleteDirectory, #deleteFile, #setUserAtHost
Constructor Details
#initialize(shell, scpProgram) ⇒ ExternalSshScp
Returns a new instance of ExternalSshScp.
293 294 295 296 297 |
# 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 |
Instance Attribute Details
#scpCommandString ⇒ Object (readonly)
The SCP command as a string
291 292 293 |
# File 'lib/synqa.rb', line 291 def scpCommandString @scpCommandString end |
#scpProgram ⇒ Object (readonly)
The SCP client, e.g. [“scp”] or [“pscp”,“-pw”,“mysecretpassword”] (i.e. command + args as an array)
288 289 290 |
# File 'lib/synqa.rb', line 288 def scpProgram @scpProgram end |
#shell ⇒ Object (readonly)
The SSH client, e.g. [“ssh”] or [“plink”,“-pw”,“mysecretpassword”] (i.e. command + args as an array)
285 286 287 |
# File 'lib/synqa.rb', line 285 def shell @shell end |
Instance Method Details
#copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) ⇒ Object
copy a local file to a remote directory (if dryRun is false)
318 319 320 |
# File 'lib/synqa.rb', line 318 def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) executeCommand("#{@scpCommandString} #{sourcePath} #{userAtHost}:#{destinationPath}", dryRun) end |
#copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) ⇒ Object
copy a local directory to a remote directory (if dryRun is false)
313 314 315 |
# File 'lib/synqa.rb', line 313 def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) executeCommand("#{@scpCommandString} -r #{sourcePath} #{userAtHost}:#{destinationPath}", dryRun) end |
#ssh(commandString, dryRun) ⇒ Object
execute command on remote host (if dryRun is false), yielding lines of output
300 301 302 303 304 305 306 307 308 309 310 |
# 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 |