From: Dossy Date: 2002-06-16T22:48:15+09:00 Subject: Re: Question: how to do (repeated) bidirectional communication with another process via stdin/stdout ? On 2002.06.16, Carsten Gronski wrote: > Thanks, but flushing won' t help. Something like this does not work. > the program hangs, when trying the second write. > .. > if (ke != nil) > ke.syswrite(loginCall) > ke.flush() > ke.each("\n") { |line| puts(line) } > # we get until here > # this does not get through Right, because the #each will iterate until the remote side closes their end. What you need to do is read only as many lines as you need or expect or read until a certain string is received, or what have you. If you're going to use EOF to signal "end of transmission" then that's what you'll have to use, but then you can't continue to send and receive like you want. You need to designate some kind of EOT (end of transmission) sequence so you can keep the connection open. > ke.syswrite(sysInfoCall) > ke.flush() > # we never get here -- program hangs !! > ke.close_write > ke.each("\n") { |line| puts(line) } > ke.close > end -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)