Ruby: Write to stdin and read from stdout?
Try closing stdin before reading the output. Here's an example:
require 'open3'
Open3.popen3("./MyProgram") do |i, o, e, t|
i.write "Hello World!"
i.close
puts o.read
end
Here's a more succint way of writing it using Open3::capture3
: (beware, untested!)
o, e, s= Open3.capture3("./MyProgram", stdin_data: "Hello World!")
puts o