Top Level Namespace
Defined Under Namespace
Modules: Spitfire
Instance Method Summary collapse
Instance Method Details
#channel_execute(session, command, prefix = '') ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spitfire.rb', line 6 def channel_execute(session, command, prefix = '') $stdout.sync return session.open_channel do |ch| $stdout.print "#{prefix} !! #{command}" ch.exec command do |ch| ch.on_data do |c,data| $stdout.print "#{prefix}> #{data}" end ch.on_extended_data do |ch, type, data| $stderr.print "#{prefix}:ERR> #{data}" end ch.on_eof do |ch| $stdout.print "#{prefix} [eof]" end ch.on_close do |ch| $stdout.print "#{prefix} [closed]" end end ch.wait end end |