From: Stephan Wehner Date: 2007-05-26T02:28:42+09:00 Subject: Pipes and flush So I wrote a little Ruby script using pipes roughly like this -- BEGIN SCRIPT ---- #!/usr/bin/ruby -n def process(line) f = IO.popen('some_executable', 'w') f.puts < result the "some_executable" prints to STDOUT results as I expect (given the lines from input_file) and I can read the results in the "result" file However, the output of the puts / puts line at the end of the process method does not occur at the places I expect. The output of "some_executable" for several "lines" shows up on STDOUT, then the output of the puts / puts line for several "lines" shows up on STDOUT, whereas they should simply alternate (depending on the "line" value). Am I missing something about pipes, and how the input/output streams are hooked up? I am guessing that a calling STDOUT.flush before and after the puts/puts line statements will repair this, but I'm wondering why this would be necessary. This is with ruby 1.8.4 (2005-12-24) [i386-linux] Thanks Stephan -- Posted via http://www.ruby-forum.com/.