Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 如何使用popen3进行读写操作?_Ruby - Fatal编程技术网

Ruby 如何使用popen3进行读写操作?

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

我正在使用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)
  puts stdout.read
  stdin.close
end

欢迎来到堆栈溢出。我肯定有一个问题在等着你出来。请阅读“”,包括链接。如果你想做那样的事,为什么不呢?那代码怎么了?如果有什么不对劲,也读一下“”。@管理员我更新了我的问题。有什么想法吗?您的其他程序是否刷新了$stdout?欢迎使用堆栈溢出。我肯定有一个问题在等着你出来。请阅读“”,包括链接。如果你想做那样的事,为什么不呢?那代码怎么了?如果有什么不对劲,也读一下“”。@管理员我更新了我的问题。有什么想法吗?你的其他程序是否刷新了$stdout?
t = gets.chomp
puts "10"
t = gets.chomp
puts t+t