Ruby on rails 在rails中实时捕获标准输出
我正在从一个函数中启动cap任务和其他命令行脚本,但我想知道显示实时日志的最佳方式是什么。我在这段代码中找到了解决方案Ruby on rails 在rails中实时捕获标准输出,ruby-on-rails,command-line-interface,Ruby On Rails,Command Line Interface,我正在从一个函数中启动cap任务和其他命令行脚本,但我想知道显示实时日志的最佳方式是什么。我在这段代码中找到了解决方案 STDOUT.sync = true IO.popen(command+" 2>&1") do |pipe| pipe.sync = true while str = pipe.gets puts "-> "+str end end
STDOUT.sync = true
IO.popen(command+" 2>&1") do |pipe|
pipe.sync = true
while str = pipe.gets
puts "-> "+str
end
end