hi alex!

i'm sorry, i didn't follow the whole thread, but you probably want
to modify your simple example like so:

---- [ foo.rb ] ----
  # immediately flush all output to the underlying OS
  STDOUT.sync = true

  10.times do |i|
    puts i
    sleep 0.5
  end
--------------------

---- [ test.rb ] ----
  IO.popen('./foo.rb') { |f|
    until f.eof?
      puts f.gets
    end
  }
---------------------

Alex Wayne [2008-04-08 22:29]:
> So it looks the block passed to popen isnt even getting called
> until the command that it invokes exits.
well, output is buffered first. only when that buffer is filled,
your receiving end of the pipe will see it. which, in this case,
coincides with the program's exit. if you don't want buffering to
happen, you have to set the sync mode to true (see [1]).

> Then the variable passed into the block is the entire output of
> that command?
it just reads the first line from that output, that's what IO#gets
does (see [2]).

[1] <http://www.ruby-doc.org/core/classes/IO.html#M002288>
[2] <http://www.ruby-doc.org/core/classes/IO.html#M002297>

hth
jens

-- 
Jens Wille, Dipl.-Bibl. (FH)
prometheus - Das verteilte digitale Bildarchiv fr Forschung & Lehre
Kunsthistorisches Institut der Universitt zu Kln
Albertus-Magnus-Platz, D-50923 Kln
Tel.: +49 (0)221 470-6668, E-Mail: jens.wille / uni-koeln.de
http://www.prometheus-bildarchiv.de/