Class: Net::SSH::Connection::Session
- Inherits:
-
Object
- Object
- Net::SSH::Connection::Session
- Defined in:
- lib/factor/connector/ssh.rb
Defined Under Namespace
Classes: CommandExecutionFailed
Instance Method Summary collapse
Instance Method Details
#exec_sc!(command) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/factor/connector/ssh.rb', line 12 def exec_sc!(command) stdout_data,stderr_data = "","" exit_code,exit_signal = nil,nil self.open_channel do |channel| channel.exec(command) do |_, success| raise CommandExecutionFailed, "Command \"#{command}\" was unable to execute" unless success channel.on_data do |_,data| stdout_data += data end channel.on_extended_data do |_,_,data| stderr_data += data end channel.on_request("exit-status") do |_,data| exit_code = data.read_long end channel.on_request("exit-signal") do |_, data| exit_signal = data.read_long end end end self.loop { stdout:stdout_data, stderr:stderr_data, exit_code:exit_code, exit_signal:exit_signal } end |