open("|cmd"..) is the simplest, but if you want a simple way to examine
the output you can use popen and a thread:



bc = IO.popen('bc','r+')

# A thread which just reads output from bc and prints it
bcout = Thread.new {
  while !bc.eof
    puts "BC says: #{bc.gets}"
  end
}

# Now let's control bc:

bc.puts "3*2"
bc.puts "4*8"

sleep 2
bc.puts "41958/999"

# Remember we need to send a quit so that the process ends!
bc.puts "quit"

# Make sure to wait for the bcout read loop to finish before we exit
bcout.join

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