From: Luke Date: 2007-06-11T03:05:05+09:00 Subject: Re: Interacting with a long-lived external process from ruby? OK - I figured it out. The process I am interacting with has similar behavior to the irb shell application. What I didn't realize was that when the process writes to the stream that I'm reading on, the prompt line does not include an EOL character. This was blocking the read stream until either write_stream.close or other output was forced. Essentially, I just decorated my process and implemented a read method as follows: ----------------8<----------------- def read line = '' response = '' while(!r.eof?) char = r.getc.chr line += char if(line == '(fcsh)') response += "[PROMPT] #{line}" break end if(char == "\n") response += "[FCSH] #{line}" line = '' end end return response end ---------------->8----------------- IO.getc being the key component as it returns every byte that is written to the stream, without regard for EOL characters. This read method behaves similarly to the IO.read method except it will return when the prompt is encountered. Also - As it turns out Open3.popen3 works just fine and is much simpler than what I was using before. Thanks, Luke Bayes http://www.asserttrue.com