From: "Ara.T.Howard" Date: 2004-04-28T08:24:03+09:00 Subject: Re: popen issues On Wed, 28 Apr 2004, Kristof Bastiaensen wrote: > Hi, > > It is maybe not a good idea to use /bin/bash as a pipe, because it is an > interactive interpreter, and not made for pipe-communication. Normally you > would just check for an end of file byte, but bash will not send you one. > Is there any reason to use bash? really? mine does: ~ > ruby -e 'p IO.popen("bash -c exit").eof?' true ~ > uname -srm && bash --version uname -srm && bash --version Linux 2.4.20-30.73ncirt i686 GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu) Copyright 2001 Free Software Foundation, Inc. how about you? -a > > > On Wed, 28 Apr 2004 06:06:30 +0900, 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 > > -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================