For this task, you can use IO.popen to get the file stream in the pipe of the growing command line result. Then use the readline function during the loop. Here is an example with the adb logcat command, which receives a live log on an Android device:
#! /usr/bin/env ruby IO.popen("adb logcat") do |io| while line = io.readline line.strip!
EDIT
For a file, this is slightly different. I would have a "readline" in a poll in a file stream.
#! /usr/bin/env ruby File.open("test.log") do |io| loop do begin line = io.readline line.strip! rescue sleep 0.2 retry end
source share