Skip to content

Instantly share code, notes, and snippets.

@TvL2386
Last active December 15, 2015 03:39
Show Gist options
  • Save TvL2386/5195772 to your computer and use it in GitHub Desktop.
Save TvL2386/5195772 to your computer and use it in GitHub Desktop.
using popen4
require 'popen4'
cmd = "ls /tmp"
status = POpen4::popen4(cmd) do |stdout,stderr,stdin,pid|
stdin.close
# get the stdout
puts "stdout: #{stdout.read.inspect}"
# get the stdin
puts "stderr: #{stderr.read.inspect}"
# get the PID
puts "pid: #{pid}"
end
puts "exitstatus: #{status.exitstatus}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment