Class: MKIt::CmdRunner
- Inherits:
-
Object
- Object
- MKIt::CmdRunner
- Defined in:
- lib/mkit/cmd_runner.rb
Class Method Summary collapse
Class Method Details
.run(cmd) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mkit/cmd_runner.rb', line 6 def self.run(cmd) result='' begin shell = PTY.spawn( cmd ) begin shell[0].each { |line| result << line.strip! } rescue Errno::EIO # nothing ensure shell[0].close end shell[1].close Process.wait(shell[2]) rescue PTY::ChildExited # nothing end raise CmdRunnerException.new("command '#{cmd[0..30]}...' returned an error response") if !$?.nil? && $?.exitstatus != 0 result end |