From: Roger Pack Date: 2011-05-13T22:48:27+09:00 Subject: Re: Shell pipeline in Ruby? Roger Pack wrote in post #998434: > In the spirit of the recent call for better ruby documentation, I wrote > a > writeup: > > http://en.wikibooks.org/w/index.php?title=Ruby_Programming/Running_Multiple_Processes&stable=0#Chaining_processes Unfortunately it appears the wiki formatting is mangled in firefox, but works well in chrome :) Here's the complete code snippet: pipe_me_in, pipe_peer_out = IO.pipe pipe_peer_in, pipe_me_out = IO.pipe fork do STDIN.reopen(pipe_peer_in) STDOUT.reopen(pipe_peer_out) Kernel.exec("echo 33") # this line is never executed because exec moves the process end pipe_peer_out.close # file handles have to all be closed in order for the "read" method, below, to be able to know # that it's done reading data, so it can return. See also http://devver.wordpress.com/2009/10/22/beware-of-pipe-duplication-in-subprocesses/ pipe_me_in.read There is a link in there to a blog describing ruby's shell class, perhaps you did not see it? -r -- Posted via http://www.ruby-forum.com/.