From: ara.t.howard@... Date: 2006-07-27T04:18:38+09:00 Subject: Re: Question about Session [was: Driving Oracle sqlplus with open3] On Thu, 27 Jul 2006, Daniel Berger wrote: > ara.t.howard@noaa.gov wrote: > > > >> drive it via session or under sh - that way your environment will be picked >> up. >> >> -a > > Session looks interesting Ara, but how do I pass input to, say, an > interactive script? The README shows only output and error handles. > > Thanks, > > Dan harp:~ > cat a.rb # system 'gem install session' require 'rubygems' rescue nil require 'session' # # initialize with /bin/sh, there are other shells supported too # sh = Session::Sh.new # # with redirects # stdin, stdout, stderr = '42', '', '' sh.execute 'cat', 'stdin' => stdin, 'stdout' => stdout, 'stderr' => stderr puts stdout # # same thing # stdin, stdout, stderr = '42', '', '' sh.execute 'cat', :stdin => stdin, :stdout => stdout, :stderr => stderr puts stdout # # same thing, for weak wrists # stdin, stdout, stderr = '42', '', '' sh.execute 'cat', 0 => stdin, 1 => stdout, 2 => stderr puts stdout # # note that this is __one__ instance of /bin/sh - so variables/state persist # between calls # sh.execute 'var=42' sh.execute 'echo "var : $var"', 1=>STDOUT harp:~ > ruby a.rb 42 42 42 var : 42 -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama