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 POpen4错误倒带stderr_Ruby - Fatal编程技术网

Ruby POpen4错误倒带stderr

Ruby POpen4错误倒带stderr,ruby,Ruby,希望产生一个进程,我可以发出多个命令。希望调用一个bat文件为这个派生的流程设置一些环境变量,然后在不影响其他流程的情况下利用这些变量 最终在POPEN4上结束,这似乎正是我想要的,但在stderr.rewind的倒带上看到了一个错误 使用下面popen4提供的示例并查看以下输出 C:\>ruby envread.rb pid : 4452 stdout : Microsoft Windows [Version 6.1.7601] Copyright (c) 2009

希望产生一个进程,我可以发出多个命令。希望调用一个bat文件为这个派生的流程设置一些环境变量,然后在不影响其他流程的情况下利用这些变量

最终在POPEN4上结束,这似乎正是我想要的,但在stderr.rewind的倒带上看到了一个错误

使用下面popen4提供的示例并查看以下输出

C:\>ruby envread.rb
pid        : 4452
stdout     : Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\>echo hello world!
hello world!

C:\>echo ERROR!  1>&2

C:\>
stderr     : ERROR!
C:/Ruby193/lib/ruby/gems/1.9.1/gems/POpen4-0.1.4/lib/popen4.rb:60:in `rewind': invalid argument (Errno::EINVAL)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/POpen4-0.1.4/lib/popen4.rb:60:n `block in popen4'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-open3-19-0.0.2/lib/win32/open3.rb:6:in `call'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-open3-19-0.0.2/lib/win32/open3.rb:6:in `block in popen4'
    from C:/Ruby193/lib/ruby/1.9.1/open3.rb:208:in `popen_run'
    from C:/Ruby193/lib/ruby/1.9.1/open3.rb:90:in `popen3'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/win32-open3-19-0.0.2/lib/win32/open3.rb:5:in `popen4'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/POpen4-0.1.4/lib/popen4.rb:48:in `popen4'
    from envread.rb:8:in `<main>'

我做错了什么?

要求使用“win32/open3”并调用Open4.popen4似乎让我绕过了这个错误,但我仍然不知道为什么倒带会失败
> rewind → 0 click to toggle source Positions ios to the beginning of
> input, resetting lineno to zero.
> 
> f = File.new("testfile") f.readline   #=> "This is line one\n"
> f.rewind     #=> 0 f.lineno     #=> 0 f.readline   #=> "This is line
> one\n" Note that it cannot be used with streams such as pipes, ttys,
> and sockets.