From: ara.t.howard@... Date: 2006-07-27T05:53:36+09:00 Subject: Re: Driving Oracle sqlplus with open3 On Thu, 27 Jul 2006, Daniel Berger wrote: >> bash.execute cmd, 0 => sql+quit, 1 => STDOUT, 2 => STDERR > > > > Excellent! That worked, thanks. The only think I noticed was that I had to > add an explicit newline to the sql statement to get it to work (but remember > to keep the semicolon). > > For future Googlers, it's probably easier to parse the output if you connect > with sqlplus -S (silent mode). > > Many thanks, > > Dan ok. if that worked, and it's all you really need to do, something like this may be simpler and not require session require 'tempfile' require 'open3' tmp = Tempfile.new rand.to_s tmp.write "your sql commands;\nquit" tmp.close Open3::open3('sh') do |i,o,e| i.puts "your sql shell command < #{ tmp.path }" i.close ot = Thread.new{ o.each{|line| STDOUT.puts line} } et = Thread.new{ e.each{|line| STDERR.puts line} } ot.join et.join end food for thought. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama