Last active
December 15, 2015 03:39
-
-
Save TvL2386/5195772 to your computer and use it in GitHub Desktop.
using popen4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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