Method: Subprocess.check_output
- Defined in:
- lib/subprocess.rb
.check_output(cmd, opts = {}, &blk) ⇒ String
Like check_call, but return the contents of stdout, much like ‘Kernel#system`.
84 85 86 87 88 89 90 |
# File 'lib/subprocess.rb', line 84 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 |