class Synqa::SshContentHost
Representation of a remote system accessible via SSH
Attributes
The remote SSH/SCP login, e.g. SSH via “username@host.example.com”
Public Class Methods
Synqa::DirContentHost::new
# File lib/synqa.rb, line 330 def initialize(userAtHost, hashCommand, sshAndScp = nil) super(hashCommand) @sshAndScp = sshAndScp != nil ? sshAndScp : InternalSshScp.new() @sshAndScp.setUserAtHost(userAtHost) end
Public Instance Methods
# File lib/synqa.rb, line 340 def closeConnections() @sshAndScp.close() end
copy a local file to a remote directory, if dryRun is false
# File lib/synqa.rb, line 374 def copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) sshAndScp.copyLocalFileToRemoteDirectory(sourcePath, destinationPath, dryRun) end
copy a local directory to a remote directory, if dryRun is false
# File lib/synqa.rb, line 369 def copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) sshAndScp.copyLocalToRemoteDirectory(sourcePath, destinationPath, dryRun) end
delete a remote directory, if dryRun is false
# File lib/synqa.rb, line 359 def deleteDirectory(dirPath, dryRun) sshAndScp.deleteDirectory(dirPath, dryRun) end
delete a remote file, if dryRun is false
# File lib/synqa.rb, line 364 def deleteFile(filePath, dryRun) sshAndScp.deleteFile(filePath, dryRun) end
Return a list of all subdirectories of the base directory (as paths relative to the base directory)
# File lib/synqa.rb, line 379 def listDirectories(baseDir) baseDir = normalisedDir(baseDir) puts "Listing directories ..." directories = [] baseDirLen = baseDir.length ssh(findDirectoriesCommand(baseDir).join(" ")) do |line| puts " #{line}" if line.start_with?(baseDir) directories << line[baseDirLen..-1] else raise "Directory #{line} is not a sub-directory of base directory #{baseDir}" end end return directories end
Yield lines of output from the command to display hash values and file names of all files within the base directory
# File lib/synqa.rb, line 397 def listFileHashLines(baseDir) baseDir = normalisedDir(baseDir) remoteFileHashLinesCommand = findFilesCommand(baseDir) + ["|", "xargs", "-r"] + @hashCommand.command ssh(remoteFileHashLinesCommand.join(" ")) do |line| puts " #{line}" yield line end end
List all files within the base directory to stdout
# File lib/synqa.rb, line 407 def listFiles(baseDir) baseDir = normalisedDir(baseDir) ssh(findFilesCommand(baseDir).join(" ")) do |line| puts " #{line}" end end
Return readable description of base directory on remote system
# File lib/synqa.rb, line 345 def locationDescriptor(baseDir) baseDir = normalisedDir(baseDir) return "#{userAtHost}:#{baseDir} (connect = #{shell}/#{scpProgram}, hashCommand = #{hashCommand})" end
execute an SSH command on the remote system, yielding lines of output (or don't actually execute, if dryRun is false)
# File lib/synqa.rb, line 352 def ssh(commandString, dryRun = false) sshAndScp.ssh(commandString, dryRun) do |line| yield line end end
# File lib/synqa.rb, line 336 def userAtHost return @sshAndScp.userAtHost end