Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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中从系统调用收集Exe printf输出_Ruby - Fatal编程技术网

在Ruby中从系统调用收集Exe printf输出

在Ruby中从系统调用收集Exe printf输出,ruby,Ruby,我想将系统调用的exe文件(foo.exe)的printf输出存储在ruby中,并获取退出状态。我该怎么做?是最好的方法 require 'open3' Open3.popen3('foo.exe') do |stdin, stdout, stderr, thr| status = thr.value output = stdout.read errors = stderr.read end 可能会有帮助

我想将系统调用的exe文件(foo.exe)的printf输出存储在ruby中,并获取退出状态。我该怎么做?

是最好的方法

require 'open3'
Open3.popen3('foo.exe') do |stdin, stdout, stderr, thr|
  status = thr.value
  output = stdout.read
  errors = stderr.read
end
可能会有帮助