我正在编写一些带有文件的代码,将该文件传递给多个二进制文件之一进行处理,并监视转换过程中的错误.我已经在OSX上编写并测试了以下例程,但linux因为我不清楚的原因而失败了.
#run the command, capture the output so it doesn't display
PTY.spawn(command) {|r,w,pid|
until r.eof? do
##mark
puts r.readline
end
}
Run Code Online (Sandbox Code Playgroud)
运行的命令变化很大,##标记处的代码已简化为本地回显以尝试调试问题.该命令执行,脚本在终端中打印预期的输出,然后抛出异常.
它在Debian系统上产生的错误是: Errno::EIO (Input/output error - /dev/pts/0):
我可以提出的所有命令字符串都会产生错误,当我运行没有本地echo块的代码时,它运行得很好:
PTY.spawn(command) {|r,w,pid|}
Run Code Online (Sandbox Code Playgroud)
在任何一种情况下,命令本身执行正常,但似乎debian linux没有发送eof up the pty.PTY文档页面和ruby-doc上的IO似乎没有任何帮助.
有什么建议?谢谢.
-vox-