I am writing a Rake task that boots an EC2 instance and runs some commands on it.
AWS' Ruby SDK has:
instance.console_output
, which returns a String
of the full output (from the moment the machine booted until present).
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.
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?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.