I would like to control a separate process with a classic 1), 2), 3), etc. menu system. Similar to piping an input file in to control the process, I would like to use Ruby to control the process' $stdin and $stdout. I've experimented with IO.popen and Open3.popen3, but cannot seem to get it to work. The documentation examples are not clear (but I'm also quite new to this sort of programming).
The basic idea is:
Open3.popen3("./server") do |stdin,stdout,stderr|
stdout.gets
stdin.puts "1"
stdout.gets
stdin.puts "2"
stdout.gets
end
Currently, the first stdout.gets gets the correct header, but then the program seems to hang. Can anybody offer any advice? I've been googling for a while now but haven't found anything.
Thanks!