Class: Proclib::Commands::SshCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/proclib/command.rb

Constant Summary collapse

SSHError =
Class.new(Error)

Constants inherited from Command

Command::NotYetRunning, Command::NotYetTerminated

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ssh:, **args) ⇒ SshCommand

Returns a new instance of SshCommand.



70
71
72
73
# File 'lib/proclib/command.rb', line 70

def initialize(ssh:, **args)
  @ssh_opts = ssh.clone
  super(**args)
end

Instance Attribute Details

#ssh_optsObject (readonly)

Returns the value of attribute ssh_opts.



66
67
68
# File 'lib/proclib/command.rb', line 66

def ssh_opts
  @ssh_opts
end

Instance Method Details

#spawnObject



75
76
77
78
79
80
81
82
83
# File 'lib/proclib/command.rb', line 75

def spawn
  write_pipes

  open_channel do |ch|
    ch.exec(cmdline) do |_, success|
      raise SSHError, "Command Failed" unless success
    end
  end
end

#waitObject



85
86
87
# File 'lib/proclib/command.rb', line 85

def wait
  ssh_session.loop
end