Created
May 10, 2013 15:38
-
-
Save joeytrapp/5555232 to your computer and use it in GitHub Desktop.
Run a shell command and pipe the stdout to to parent process.
This file contains hidden or 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
task :test do | |
cmd = 'shell command to run' | |
rd, wr = IO::pipe | |
pid = Process.fork do | |
$stdout.reopen(wr) | |
rd.close | |
exec(cmd) | |
end | |
wr.close | |
rd.each { |line| puts line } | |
Process.wait(pid) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment