F
Forrest Chang
HI All:
For the following code segement running on win32 ruby (1 click installer)
sout = IO.popen( "output");
while( line = sout.gets)
do_something_with( line)
end
If for example, "output" printed out something 5 times every second,
then on the command line, I would see something printed out every
second, 5 times. Running through the above code, I would not see
anything until after 5 secs, which I assume that after the program
exits, the output is flushed, and then it would be all 5 entries. I
ran the same sort of code successfully solaris, so I expected it to
work on windows.
I did an experiment, and wrote a ruby program that printed a
line then flushed STDOUT, paused, repeated, etc., and it works as
suspected. Since I do not have control over the actual "output"
program, how can I get it so that each line is flushed? sout.sync =
true didn't work (I imagine it only works if I write to sout)
Any ideas?
Thanks
FOrrest
For the following code segement running on win32 ruby (1 click installer)
sout = IO.popen( "output");
while( line = sout.gets)
do_something_with( line)
end
If for example, "output" printed out something 5 times every second,
then on the command line, I would see something printed out every
second, 5 times. Running through the above code, I would not see
anything until after 5 secs, which I assume that after the program
exits, the output is flushed, and then it would be all 5 entries. I
ran the same sort of code successfully solaris, so I expected it to
work on windows.
I did an experiment, and wrote a ruby program that printed a
line then flushed STDOUT, paused, repeated, etc., and it works as
suspected. Since I do not have control over the actual "output"
program, how can I get it so that each line is flushed? sout.sync =
true didn't work (I imagine it only works if I write to sout)
Any ideas?
Thanks
FOrrest