Running an interactive program from Ruby
I am trying to run gnuplot from ruby (not using an external gem) and parsing its textual output also. I tried IO.popen , PTY.spawn and Open3.popen3 but whenever I try to get the output it just "hangs" -I guess waiting for more output to come. I feel like its somehow done using Thread.new but I couldn't find the correct way to implement it. Anyone know how it is done? I guess this is what you want: require 'pty' require 'expect' PTY.spawn('gnuplot') do |input, output, pid| str = input.expect(/gnuplot>/) puts str output.puts "mlqksdf" str = input.expect(/gnuplot>/) puts str output.puts "exit"