【问题标题】:How to use popen3 library in Windows?如何在 Windows 中使用 popen3 库?
【发布时间】:2015-07-10 04:01:26
【问题描述】:

我尝试了这些 SO 帖子和博客中的所有代码(主要是 popen 或 open gem) - http://blog.bigbinary.com/2012/10/18/backtick-system-exec-in-ruby.html

由于错误,没有任何效果 -

C:/svn/ruby/lib/ruby/1.8/open3.rb:57:in `fork': fork() function is unimplemented on this machine (NotImplementedError)
        from C:/svn/ruby/lib/ruby/1.8/open3.rb:57:in `popen3'

示例代码 -

require 'open3'
cmd = 'git push heroku master'
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
  puts "stdout is:" + stdout.read
  puts "stderr is:" + stderr.read
end

如何使用这个旧的 ruby​​ 1.8 gem 进行这项工作?

【问题讨论】:

    标签: ruby windows command-line cmd


    【解决方案1】:

    open3 gem 无法在 Windows 上运行。 =/

    IO::popen 是我能想到的最接近的东西。

    【讨论】:

    • IO::popen 不会捕获STDERR,因此无法以相同的方式进行操作。现在,如果您正在尝试做一些特定的事情,那么您可能应该在另一个问题中问它,因为这个问题的答案是“您不能在 Windows 中使用 open3。”
    猜你喜欢
    • 1970-01-01
    • 2012-02-15
    • 2016-12-25
    • 2016-05-31
    • 1970-01-01
    • 2014-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多