On Tue, 9 Jan 2007, Aleksandr Levchuk wrote:

> It was surprising when the following code froze:
>
> require 'open3'
> i, o, e = Open3::popen3('/bin/bash')
> c = o.getc
> puts c.chr # expecting the first character of my bash prompt

man bash: it behaves differently depending on whether it's a login shell or
not and whether connected to a tty or not.  you may want to try out my session
lib

   harp:~ > cat a.rb
   require 'rubygems' # gem install session - http://rubyforge.org/projects/codeforpeople/
   require 'session'

   bash = Session::Bash.new

   stdout, stderr = bash.execute 'export a=42'

   stdout, stderr = bash.execute 'echo $a'
   puts stdout

   bash.execute 'date', :stdout => STDOUT



   harp:~ > ruby a.rb
   42
   Tue Jan  9 08:00:47 MST 2007


regards.

-a
-- 
in the practice of tolerance, one's enemy is the best teacher.
- the dalai lama