#!/opt/bin/perl # ######################################################################### # # # Program to list excerpt of logfile of concerned users # # # ######################################################################### # # # Version 1.0 - Written 07.11.95 by Steffen Beyer # # # ######################################################################### # # # Copyright (C) 1995 by software design & management GmbH & Co. KG # # # ######################################################################### # # User configurable constants: # ######################################################################### # $rootdir = '/u/www/.www'; # $application = 'traverse_html'; # $logfile = "$rootdir/$application.log"; # ######################################################################### # # Some internal variables: # $version = 'version 1.0'; # $self = $0; $self =~ s!^.*/!!; # $tempfile = "/tmp/$self.temp.$$"; # # Open logfile: # unless (open(LOGFILE, "<$logfile")) { die "$self: can't read '$logfile': $!\n"; } # $open = 0; $list = 0; # while () { if (/^-+$/) { &listfile; unless (open(TEMPFILE, ">$tempfile")) { die "$self: can't write '$tempfile': $!\n"; } $open = 1; $list = 0; } elsif (/^visiting/) { if ($open) { print TEMPFILE; } } elsif (/^can't find/) { $list = 1; if ($open) { print TEMPFILE; } } elsif (/^\(coming from/) { if ($open) { print TEMPFILE; } } else { } } # close(LOGFILE); # # List file if one is still open: # &listfile; # # Done: # exit; # # Subroutine that lists the file: # sub listfile { if ($open) { $open = 0; close(TEMPFILE); if ($list) { $list = 0; unless (open(TEMPFILE, "<$tempfile")) { die "$self: can't read '$tempfile': $!\n"; } print STDOUT ('-' x 78), "\n"; while () { print STDOUT; } print STDOUT ('-' x 78), "\n"; close(TEMPFILE); } if (unlink($tempfile) != 1) { die "$self: can't delete '$tempfile'!\n"; } } } # # END: # __END__