On Wed, 20 Sep 2006, Caio Chassot wrote: > > On 2006-09-19, at 22:24 , Daniel N wrote: > >> >> Again, I havn't used it before, but the IO#pipe command seems to allow for >> bi-directional control. > > Yea, I figured out how to open a pipe for both read and write. You use a > numeric mode. Here's what I got: > > #!/usr/bin/env ruby > io = File.popen('perl -pe s/a/b/g', 0666) > io.puts('abc') > io.close_write > puts io.read > > outputs: > bbc > > So it's fine for my needs. I just need to wrap it into something more > idiomatic. > > Thanks Paul and Daniel > you're making it pretty hard on yourself: harp:~ > cat a.rb cat = IO.popen 'cat', 'r+' cat.sync = true cat.puts 'foobar' puts cat.gets cat.puts 'barfoo' puts cat.gets harp:~ > ruby a.rb foobar barfoo my session and open4 lib both abstract this largely, including a good deal of error handling. there is also the built-in open3 module. check out the docs. regards. -a -- in order to be effective truth must penetrate like an arrow - and that is likely to hurt. -- wei wu wei