Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4489

Re: Shell pipeline in Ruby?

From Roger Pack <rogerpack2005@gmail.com>
Newsgroups comp.lang.ruby
Subject Re: Shell pipeline in Ruby?
Date 2011-05-13 08:48 -0500
Organization Service de news de lacave.net
Message-ID <51b4f0fd6ff287e356ae26e5b951f3ae@ruby-forum.com> (permalink)
References <BANLkTik15O2NLu4grCfhbtF3Ws6N_c4Qtg@mail.gmail.com> <00489613d64495c765cada2702102dd7@ruby-forum.com>

Show all headers | View raw


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/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-12 11:05 -0500
  Re: Shell pipeline in Ruby? Jos Backus <jos@catnook.com> - 2011-05-12 12:22 -0500
    Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-12 14:41 -0500
      Re: Shell pipeline in Ruby? Stu <stu@rubyprogrammer.net> - 2011-05-12 14:54 -0500
        Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-12 15:15 -0500
  Re: Shell pipeline in Ruby? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-12 13:06 -0500
  Re: Shell pipeline in Ruby? Roger Pack <rogerpack2005@gmail.com> - 2011-05-12 22:13 -0500
    Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-13 03:33 -0500
      Re: Shell pipeline in Ruby? Roger Pack <rogerpack2005@gmail.com> - 2011-05-13 08:44 -0500
    Re: Shell pipeline in Ruby? Roger Pack <rogerpack2005@gmail.com> - 2011-05-13 08:48 -0500
      Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-13 13:14 -0500
  Re: Shell pipeline in Ruby? Robert Klemme <shortcutter@googlemail.com> - 2011-05-13 03:44 -0500
    Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-13 08:27 -0500
      Re: Shell pipeline in Ruby? Robert Klemme <shortcutter@googlemail.com> - 2011-05-13 09:23 -0500
        Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-13 12:44 -0500
  Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-13 10:32 -0500
    Re: Shell pipeline in Ruby? Brian Candler <b.candler@pobox.com> - 2011-05-14 10:05 -0500
      Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-16 06:05 -0500
  Re: Shell pipeline in Ruby? Brian Candler <b.candler@pobox.com> - 2011-05-14 10:14 -0500
  Re: Shell pipeline in Ruby? Michal Suchanek <hramrach@centrum.cz> - 2011-05-16 10:29 -0500

csiph-web