-
-
Save xxd/8767543 to your computer and use it in GitHub Desktop.
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
#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 } | |
%x[git init] | |
matrix.each do |day| | |
if day == "o" | |
%x[git commit --allow-empty --author="#{author} <#{email}>" --date="#{date.to_time}" -m"#{date.to_time} - by: #{author}"] | |
end | |
date = date.next | |
end | |
#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