Skip to content

Instantly share code, notes, and snippets.

@joeytrapp
Created May 10, 2013 15:38
Show Gist options
  • Save joeytrapp/5555232 to your computer and use it in GitHub Desktop.
Save joeytrapp/5555232 to your computer and use it in GitHub Desktop.
Run a shell command and pipe the stdout to to parent process.
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