From: Daniel Berger Date: 2006-07-26T22:27:53+09:00 Subject: Driving Oracle sqlplus with open3 Hi all, Is it possible to drive Oracle's sqlplus (command line utility) with open3? Don't ask me why, just nod your head and accept it please. :) I seem to be able to connect and send sql, but I'm having trouble grabbing output: # Attempt to interact with the sql shell require 'open3' cmd = 'user@database' pass = 'xxxx' sql = 'select sysdate from dual;' Open3.popen3(cmd) do |stdin, stdout, stderr| puts "Sending password..." stdin.puts(pass) puts "Sending sql..." stdin.puts(sql) # Hangs here puts "Getting results" uresults = stdout.read puts "Results: #{results}" puts "Quitting..." stdin.puts('quit') end I tried wrapping the read method in its own Thread, but I couldn't make it work. Tinkering with various sync options didn't help, though perhaps I set them incorrectly. Any ideas? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.