From: Dan Janowski Date: 2004-04-30T03:33:39+09:00 Subject: Re: popen issues I think putting the process in a pty will give you better control. Dan On Apr 27, 2004, at 17:06, Hal Fulton wrote: > Here's something I've never figured out. > > Suppose I want real two-way communication with a process via popen. > This seems doable. > > But apparently the read hangs until I do a close_write; and if I > do that, I can't write again. A flush doesn't work. > > Here's what I was thinking (simplified): > > io = IO.popen("/bin/bash","r+") do |f| > f.puts "ls" > puts f.readlines > f.puts "date" > puts f.readlines > end > > I even tried this (following) abomination, to no avail: > > io = IO.popen("/bin/bash","r+") do |f| > writer = f.dup > f.puts "ls\n" > f.close_write > puts f.readlines > w = writer.dup > w.puts "date\n" > w.close_write > puts f.readlines > end > > > Can someone advise? > > > Hal > > >