From: "ara.t.howard" Date: 2007-10-07T00:21:43+09:00 Subject: Re: popen in non-blocking mode On Oct 6, 2007, at 5:17 AM, Urizev wrote: > I want to execute a program which prompts for commads from standard > input and returns responses to standard output, this process repeats > several times. I want to execute it from a ruby application. I tried > to use a popen call to do it, but it do not flush the output until > input channel is closed. I need to know what the process request > before sending a response. the general concepts are: IO.popen cmd, 'r+' do |pipe| pipe.sync = true ### you can do this once loop do buf = pipe.gets case buf when /A/ pipe.puts 'response_A' when /B/ pipe.puts 'response_B' end pipe.flush ### or this after each write end end kind regards. a @ http://codeforpeople.com/ -- share your knowledge. it's a way to achieve immortality. h.h. the 14th dalai lama