Ruby 如何使用popen3进行读写操作?
我正在使用Windows,在收到如下响应后,我想写入一个程序:Ruby 如何使用popen3进行读写操作?,ruby,Ruby,我正在使用Windows,在收到如下响应后,我想写入一个程序: 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) pu
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
欢迎来到堆栈溢出。我肯定有一个问题在等着你出来。请阅读“”,包括链接。如果你想做那样的事,为什么不呢?那代码怎么了?如果有什么不对劲,也读一下“”。@管理员我更新了我的问题。有什么想法吗?您的其他程序是否刷新了$stdout?欢迎使用堆栈溢出。我肯定有一个问题在等着你出来。请阅读“”,包括链接。如果你想做那样的事,为什么不呢?那代码怎么了?如果有什么不对劲,也读一下“”。@管理员我更新了我的问题。有什么想法吗?你的其他程序是否刷新了$stdout?
t = gets.chomp
puts "10"
t = gets.chomp
puts t+t