Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge branch 'mitchellh/process_stderr'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/net/ssh/shell/process.rb
  • Loading branch information
jamis committed Jan 7, 2011
2 parents 2cec3b5 + bd46382 commit 1f4bc83
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/net/ssh/shell/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def initialize(manager, command, callback)
@callback = callback
@properties = {}
@on_output = Proc.new { |p, data| print(data) }
@on_error_output = Proc.new { |p, data| print(data) }
@on_finish = nil
@state = :new
end
Expand All @@ -36,6 +37,7 @@ def run
manager.open do
state = :running
manager.channel.on_data(&method(:on_stdout))
manager.channel.on_extended_data(&method(:on_stderr))
manager.channel.on_close(&method(:on_close))

cmd = command.dup
Expand Down Expand Up @@ -75,6 +77,10 @@ def on_output(&callback)
@on_output = callback
end

def on_error_output(&callback)
@on_error_output = callback
end

def on_finish(&callback)
@on_finish = callback
end
Expand All @@ -96,6 +102,11 @@ def on_stdout(ch, data)
end
end

def on_stderr(ch, type, data)
return unless @on_error_output
@on_error_output.call(self, data)
end

def on_close(ch)
manager.on_channel_close(ch)
finished!(-1)
Expand Down

0 comments on commit 1f4bc83

Please sign in to comment.