ara.t.howard / noaa.gov wrote:
> On Thu, 27 Jul 2006, Daniel Berger wrote:
> 
>> I tried session like so:
>>
>> # sessiontest.rb
>> require 'rubygems'
>> require 'session'
>>
>> cmd  = 'sqlplus foo/xxx@mydb'
>> sql  = 'select sysdate from dual;'
>> quit = 'quit'
>>
>> bash = Session::Bash.new
>> bash.execute(cmd) do |output, error|
>>   if error
>>      puts "ERROR: #{error}"
>>      exit
>>   end
>>   puts output if output
>> end
>>
>> # Hangs here
>> bash.execute(:stdin=>sql) do |output, error|
>>   if error
>>      puts "ERROR: #{error}"
>>      exit
>>   end
>>   puts output if output
>> end
>>
>> bash.execute(quit) do |output, error|
>>   if error
>>      puts "ERROR: #{error}"
>>      exit
>>   end
>>   puts output if output
>> end
>>
> 
> try something like
> 
> bash.execute cmd, 0 => sql+quit, 1 => STDOUT, 2 => STDERR

<snip>

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


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.