I am writing a Rake task that boots an EC2 instance and runs some commands on it.
我正在写一个Rake任务,它启动EC2实例并在其上运行一些命令。
AWS' Ruby SDK has:
AWS的Ruby SDK具有:
instance.console_output
, which returns a String
of the full output (from the moment the machine booted until present).
instance.console_output,返回完整输出的String(从机器启动到现在的那一刻)。
What I really want is the "diff" between the last output and the current, so that I can just print the new lines to my local console.
我真正想要的是最后一个输出和当前之间的“差异”,这样我就可以将新行打印到我的本地控制台。
I feel like there should be a tool for this somewhere in a Gem or Ruby library, but searching on Google has yielded nothing.
我觉得在Gem或Ruby库中应该有一个这样的工具,但在Google上搜索却没有产生任何结果。
Any help, or am I stuck doing:
任何帮助,或者我坚持做:
total = output.lines.length
new_lines = total - last
puts output.lines[-1..new_lines].to_a.join
last = total
in a loop?
在循环中?