Skip to content

Instantly share code, notes, and snippets.

@SaitoWu
Created February 11, 2011 08:57
Show Gist options
  • Save SaitoWu/822091 to your computer and use it in GitHub Desktop.
Save SaitoWu/822091 to your computer and use it in GitHub Desktop.
exec something on ruby.
#0> non-block call
Thread.new do
blahbla...
end
#1> 4 simple ways to call shell or cmd
`ps aux`
system "ps aux"
exec "ps aux"
%x{ ps aux }
#2> open3 popen & :pid
require 'open3'
Open3.popen2 "ps aux" do |i, o, t|
:pid = t.pid
end
#3> open3 capture & :pid
require 'open3'
o,s = Open3.capture2("ps aux")
:pid = s.pid
#4 Process spawn
:pid = Process.spawn "ps aux"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment