From: Dave Thomas Date: 2001-07-30T09:19:12+09:00 Subject: [ruby-talk:18770] Re: Autoflush backquotes?? Chris Moline writes: > I am trying to get the backquotes to print everything "as it comes" > instead of after the backquotes are done. Does anyone have any idea > how to do this?? Using $stdout.sync = true does not work. Here is > the relevant part of the script You won't be able to use backquotes here, because backquotes wait for all the output to appear before returning (as that's what they are intended for). Instead, you can open a pipe to the child process and read it's output interactively. IO.popen(command) do |p| p.each do |line| puts line end end However, there's a further wrinkle. Often, programs that produce output line-by-line when you run them interactively change their behavior when run as a subprocess talking to a pipe. For example, here's a simple Ruby program: 5.times do puts "hello" sleep 1 end Run it form the command line, and it does what you expect. However, run it as the command in the popen example above, and you won't see any output until it finishes. You need to change it to $stdout.sync = true 5.times do puts "hello" sleep 1 end To get it to write the output as it's produced. Regards Dave