From: Robert Klemme Date: 2009-03-19T18:37:22+09:00 Subject: Re: Wrapping applications in Ruby On 19.03.2009 10:02, Jp Hastings-spital wrote: > Dylan Evans wrote: >> I won't go into details but you should look into pipes in this case. > > Thanks for the prompt response - I'm assuming you mean Ruby pipes not > BASH pipes or equivalent. (http://www.ruby-doc.org/core/classes/IO.html) > > I'll post here if I find a solution. I have no idea what you mean by "bash pipes" but the underlying mechanism is the same. It's a feature of the operating system. One solution is to use IO.popen. Your code does not read all the lines, that might be one reason for your issue. robert@fussel /c/Temp $ ./run-counter.rb Got 0 Got 10 Got 20 Got 30 Got 40 Got 50 Got 60 Got 70 Got 80 Got 90 Got 100 robert@fussel /c/Temp $ cat run-counter.rb #!/usr/bin/env ruby19 IO.popen "./counting.rb" do |io| io.each do |line| pct = line[%r{:\s*(\d+)%}, 1].to_i puts "Got #{pct}" end end robert@fussel /c/Temp $ cat counting.rb #!/usr/bin/env ruby19 $stdout.sync = true 11.times do |n| puts "Completed: #{n*10}%" end robert@fussel /c/Temp $ Similar with Open3, only that you then get multiple pipes. Cheers robert -- remember.guy do |as, often| as.you_can - without end