#!/usr/bin/perl # Log viewer program. Pass it parameters of the logs to view, or it will # automatically view some. use File::Find; use File::stat; $|=1; my $logdir='/var/log'; @logfiles=@ARGV; # If I am root, look at all logs, otherwise only those that are # world-readable. if (! @logfiles) { find(sub {my $fn = $_; my $stat = stat($File::Find::name); next if not defined $stat; if (($fn =~ /\.log$/ or $fn =~ /^mail\.(?:err|warn)$/) and ($stat->mode & 0006 or $> == 0)) { push @logfiles,$File::Find::name; } }, $logdir ); } if (-e $ENV{HOME}."/.xsession-errors") { push @logfiles, $ENV{HOME}."/.xsession-errors"; } # Tail without wasting the last line of the screen. open(TAIL, "tail -q --follow=name --retry -n 2 @logfiles|"); while () { print "\n"; chomp; print $_; }