1

I'm using Windows and I want write to a Programm, after I recived a respones someway like this:

Open3.popen3("ruby echo.rb") do |stdin, stdout, stderr, wait|
  stdin.puts("Hello\n")
  stdin.close
  got_this = stdout.read
  stdin.reopen # <- Not an existing function. What to do here?
  stdin.puts(got_this)
  puts stdout.read
  stdin.close
end

My problem is, that it seems like I can't read the input before closing the output stream. I already found this post but it seems like there is no PTY support on Windows: ruby popen3 -- how to repeatedly write to stdin & read stdout without re-opening process?

This is the code of the echo.rb:

t = gets.chomp
puts "10"
t = gets.chomp
puts t+t
Community
  • 1
  • 1
Daveman
  • 1,075
  • 9
  • 26
  • Welcome to Stack Overflow. I'm sure there's a question in there just waiting to get out. Please read "[ask]" including the links. If you want to do something like that, why don't you? What's wrong with that code? If there is something wrong read "[mcve]" too. – the Tin Man Jun 17 '16 at 19:41
  • @theTinMan I updated my Question. Any ideas? – Daveman Jun 17 '16 at 20:03
  • Does your other program flush `$stdout`? – tadman Jun 17 '16 at 20:24

0 Answers0