Skip to content

Instantly share code, notes, and snippets.

@jch
Created October 11, 2010 18:39
Show Gist options
  • Save jch/621005 to your computer and use it in GitHub Desktop.
Save jch/621005 to your computer and use it in GitHub Desktop.
nspipe example
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