# File lib/net/ssh/connection/session.rb, line 319
319:     def exec(command, &block)
320:       open_channel do |channel|
321:         channel.exec(command) do |ch, success|
322:           raise "could not execute command: #{command.inspect}" unless success
323:           
324:           channel.on_data do |ch2, data|
325:             if block
326:               block.call(ch2, :stdout, data)
327:             else
328:               $stdout.print(data)
329:             end
330:           end
331: 
332:           channel.on_extended_data do |ch2, type, data|
333:             if block
334:               block.call(ch2, :stderr, data)
335:             else
336:               $stderr.print(data)
337:             end
338:           end
339:         end
340:       end
341:     end