我有一个 ruby 应用程序,它使用反引号将 ant 作为子进程执行。这没有任何问题。当我执行 put ant
时,ruby 等待子进程 ant 完全完成,然后将输出打印到标准输出。如何让 ruby 连续打印子进程的输出?
最佳答案
你可以使用IO.popen
。
IO.popen("ant") do |output|
while line = output.gets do
# ... maybe puts line? something more interesting?
end
end
关于ruby - 如何在 ruby 中使用反引号开始子进程的连续输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1071585/