On Wed, 30 Aug 2006 17:02:08 +0900, Ashley Moran wrote: > On Wednesday 30 August 2006 08:34, Ashley Moran wrote: >> IO.popen("psql -U test test","r+") do |pipe| >> Thread.new { loop { pipe.read } } # fixes it >> query.each { |statement| pipe.puts statement } >> end > > > Actually I lied... I need a "sleep 2" at the end of the IO.popen block for > this to work. Is there a less magical way to sync it? (I took a stab at > Process.wait but it doesn't work.) > > Ashley > Since you're throwing away the output, instead of using a thread, why try one of the following: * popen with the mode "w" IO.popen("psql -U test test","w") * redirect the results from pgsql to /dev/null inside the popen call IO.popen("psql -U test test > /dev/null","r+") --Ken -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/