25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/net-ssh-plus.rb', line 25
def detailed_exec!(command)
ret = {}
channel = open_channel do |channel|
channel.exec(command) do |ch, success|
abort "FAILED: couldn't execute command (ssh.channel.exec failure)" unless success
channel.on_data do |ch, data| ret[:stdout] ||= ""
ret[:stdout] << data
end
channel.on_extended_data do |ch, type, data|
next unless type == 1 ret[:stderr] ||= ""
ret[:stderr] << data
end
channel.on_request("exit-status") do |ch, data|
ret[:exit_code] = data.read_long
end
channel.on_request("exit-signal") do |ch, data|
ret[:exit_signal] = data.read_long
end
end
end
channel.wait
return ret
end
|