Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Roger Pack Newsgroups: comp.lang.ruby Subject: Re: Shell pipeline in Ruby? Date: Fri, 13 May 2011 08:48:27 -0500 Organization: Service de news de lacave.net Lines: 40 Message-ID: <51b4f0fd6ff287e356ae26e5b951f3ae@ruby-forum.com> References: <00489613d64495c765cada2702102dd7@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1305294698 27095 65.111.164.187 (13 May 2011 13:51:38 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 13 May 2011 13:51:38 +0000 (UTC) In-Reply-To: <00489613d64495c765cada2702102dd7@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383206 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <51b4f0fd6ff287e356ae26e5b951f3ae@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4489 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/.