Created
October 11, 2010 18:39
-
-
Save jch/621005 to your computer and use it in GitHub Desktop.
nspipe example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework 'cocoa' | |
outpipe = NSPipe.pipe | |
task = NSTask.alloc.init | |
task.setLaunchPath '/usr/bin/tail' | |
task.setArguments %w(-f -n10 /Users/jch/projects/pharmmd/log/wendy.log) | |
task.setStandardOutput outpipe | |
file = outpipe.fileHandleForReading | |
task.launch | |
while true | |
puts "-----" | |
lines = file.availableData.to_str.split("\n") | |
puts "#{lines.size} lines" | |
puts lines.inspect | |
sleep 15 | |
puts "-----\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment