J
Joel F.
Hi,
I'd like to spawn a process, then write some stuff to it, then read from
stuff from it, then write more, then read more, etc etc. (Ruby 1.9 and
Windows)
The way that I've done this is something like:
------------------------------
require 'open3'
require 'io/wait'
input, output, err = Open3.popen3('cmd')
input.puts 'echo hi'
output.read(output.stat.size)
input.puts 'echo bye'
output.read(output.stat.size)
-------------------------------
This seems mostly okay, but I have a couple questions.
1. In IO/wait, there's a method called "ready?". If I call "ready?" in
this program, it returns false even when stat.size indicates that there
actually IS in fact data to be read. I'm having trouble understanding
it.
2. In IO/wait, there's a method called "nread". However, if I call
output.methods.sort, it's not there and I cant use it. I see "ready?"
and "wait", but no "nread".
3. I'm sure I'm not the first bozo to complain about the
documentation...but the primary documentation for ruby's standard
libraries (ruby-doc.org) is pretty sucky. I'm just feeling frustrated
atm. It took me a lot of hours to come up with the little code that I
have >_<. Is there an alternative site that has more meaningful
documentation?
I just signed up for the ruby documentation mailing list so I can make
some suggestions...but is there maybe an easier way? It would be nice
if there was just some form that I could fill out and say "on this page
it says X, but it would be more helpful if it said Y". Or even a wiki
version of the API.
joel
I'd like to spawn a process, then write some stuff to it, then read from
stuff from it, then write more, then read more, etc etc. (Ruby 1.9 and
Windows)
The way that I've done this is something like:
------------------------------
require 'open3'
require 'io/wait'
input, output, err = Open3.popen3('cmd')
input.puts 'echo hi'
output.read(output.stat.size)
input.puts 'echo bye'
output.read(output.stat.size)
-------------------------------
This seems mostly okay, but I have a couple questions.
1. In IO/wait, there's a method called "ready?". If I call "ready?" in
this program, it returns false even when stat.size indicates that there
actually IS in fact data to be read. I'm having trouble understanding
it.
2. In IO/wait, there's a method called "nread". However, if I call
output.methods.sort, it's not there and I cant use it. I see "ready?"
and "wait", but no "nread".
3. I'm sure I'm not the first bozo to complain about the
documentation...but the primary documentation for ruby's standard
libraries (ruby-doc.org) is pretty sucky. I'm just feeling frustrated
atm. It took me a lot of hours to come up with the little code that I
have >_<. Is there an alternative site that has more meaningful
documentation?
I just signed up for the ruby documentation mailing list so I can make
some suggestions...but is there maybe an easier way? It would be nice
if there was just some form that I could fill out and say "on this page
it says X, but it would be more helpful if it said Y". Or even a wiki
version of the API.
joel