Daniel Berger wrote: > 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? Some more digging reveals that I'm actually getting this back from the stdin.puts(sql) call: SP2-0306: Invalid option. Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] where <logon> ::= <username>[/<password>][@<connect_string>] | / Google indicates that this is some kind of shell issue where my environment variables aren't being picked up. I'll post a solution if/when I find one. 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.