#!/usr/local/bin/perl -w #A Perl version of the unix (tail -f) command #written by Nick (see http://illx.org for more details) #uses the 'trailing a growing file' from Perl Cookbook #NOTE: This script DOES NOT print the last 10 lines of the #file like tail does... it just reads a growing file my $log = $ARGV[0]; unless($log) { print "Won't continue with an argument!\n", "Usage: ./perltail_f /var/log/mail.log\n\n"; exit 1; } unless( -e $log ) { print "The logfile $log you specified doesn't exist, exiting...\n"; exit 1; } use IO::Handle; open(LOG, "$log") or die "Can't open $log: $!\n"; #seek to end of file seek(LOG, 0, 2); #and start watching it from there for(;;) { while() { print } #change sleep for faster or slower updating sleep 1; LOG->clearerr(); } close(LOG);