I have a problem.
I want to run a ruby script from another ruby script and capture it\'s output information while letting it output to the screen too.
STDOUT.print "Enter your password: "
password = gets.chomp
puts "Here is your password: #{password}"
Note STDOUT.print
require "stringio"
buffer = StringIO.new
$stdout = buffer
require "runner"
$stdout = STDOUT
buffer.rewind
puts buffer.read.match(/Here is your (password: .*)/).captures[0].to_s
Enter your password: hello
password: hello
I recently did a write-up on this here: Output Buffering with Ruby