jweirich / one.net writes:

> I want to start a process and feed it information through its standard
> input and read the result from its standard output.  The "popen"
> command seems to do one or the other, but not both at once.  It there
> a way to do this?  (Currently I'm using a work-around using a
> temporary file).

IO.popen does what you want. This comes from pg 121:

  pig = IO.popen("pig", "w+")
  pig.puts "ice cream after they go to bed"
  pig.close_write
  puts pig.gets
  puts 99

->
  iceway eamcray afterway eythay ogay otay edbay


There's also an open3 library.


> In a similar vein, is there an "expect"-like addon for Ruby?

Have a look in ext/pty: you get pty driving and a Tcl-like expect
facility.


Regards


Dave