Method: Z4box::Box#spawn
- Defined in:
- lib/z4box.rb
#spawn(e, p, *a) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/z4box.rb', line 43 def spawn e, p, *a channel = ssh.open_channel do |ch| ch.exec "#{e} #{p} #{a.join(' ')}" do |ch, success| raise "could not execute command" unless success # "on_data" is called when the process writes something to stdout ch.on_data do |c, data| $stdout.print data end # "on_extended_data" is called when the process writes something to stderr ch.on_extended_data do |c, type, data| $stderr.print data end ch.on_close { puts "done!" } end end channel.wait end |