Forward standard error stream from remote execution

This commit is contained in:
Thibault Jouan
2014-07-21 12:45:57 +00:00
parent a033e19583
commit db91eb06cd
14 changed files with 93 additions and 17 deletions

View File

@@ -24,13 +24,17 @@ module Producer
@fs ||= Remote::FS.new(session.sftp.connect)
end
def execute(command, output = '')
def execute(command, output = '', error_output = '')
channel = session.open_channel do |channel|
channel.exec command do |ch, success|
ch.on_data do |c, data|
output << data
end
ch.on_extended_data do |c, type, data|
error_output << data
end
ch.on_request 'exit-status' do |c, data|
exit_status = data.read_long
fail RemoteCommandExecutionError, command if exit_status != 0