Method: Subprocess.check_output
- Defined in:
- lib/subprocess.rb
.check_output(cmd, opts = {}) {|process| ... } ⇒ String
Like check_call, but return the contents of stdout, much like Kernel#system.
105 106 107 108 109 110 111 |
# File 'lib/subprocess.rb', line 105 def self.check_output(cmd, opts={}, &blk) opts[:stdout] = PIPE child = Process.new(cmd, opts, &blk) output, _ = child.communicate() raise NonZeroExit.new(cmd, child.status) unless child.wait.success? output end |