Session Gem: How to get line-by-line output from shell script using

Thanks in advance for your help! I need line-by-line output from a bash
script from inside ruby (and ultimately, rails). So far, all I can get
using IO.popen or backticks, is the output after the script has finished
executing.

Now I am trying to use a gem called "Session", which has very little
documenation.

The first code example below produces the output all at once, even
though the perl script flushes its buffer with every line ($|) and when
it runs in bash, updates the screen often.

···

----
#!/usr/local/bin/ruby
$:.unshift '.', '..', 'lib', File.join('..','lib')
require 'session'

sh = Session::new

stdout, stderr = sh.execute 'perl5.8.5 /home/test/perl2.ruby.pl'
stdout.each_line{|line| print line}

-----
This second example runs, but it does not print to the screen (stdout)
and I have yet to discover where the output 'goes'

#!/usr/local/bin/ruby
$:.unshift '.', '..', 'lib', File.join('..','lib')
require 'session'

bash = Session::Bash.new
stdout, stderr = StringIO::new, StringIO::new
bash.execute 'perl5.8.5 /home/test.perl2.ruby.pl', :stdout => stdout,
:stderr => stderr
stdout.each_line{|line| print line}
puts bash.exit_status

---------
What I am really working towards is a way to display line-by-line output
from a perl script as it executes in rails. I don't necessarily need to
use "Session::". Please let me know if you have a better way, one that
works. Thanks

--
Posted via http://www.ruby-forum.com/.

This works. I run a perl script from ruby, and get line-by-line output
as it runs.

···

---------------------
#!/usr/bin/env ruby

readme = IO.popen("/home/test/perl2.ruby.pl")
while readme.gets do
    puts $_
end
readme.close
---------------------

Thanks to
http://pleac.sourceforge.net/pleac_ruby/processmanagementetc.html

--
Posted via http://www.ruby-forum.com/.