Log Files

Steve Anderson andersons001 at hawaii.rr.com
Wed Jul 11 09:46:04 PDT 2001


Dusty’s script to create html files from the log files has proved to
save me a lot of time. Instead of logging into the machine and doing the
regular viewing of the scripts, I just use a browser from anywhere to
view the log files.  Below is my use of the script in case anyone missed
Dusty's email the first time.
Steve

#!/bin/sh
#
DATED=`date '+%d%b%H%M'`
`rm /usr/local/apache/shtdocs/*log.html`
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}' /var/log/cron >
/usr/local/apache/ shtdocs/$DATED.cron_log.html
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}'
/var/log/httpd/access_log >
/usr/local/apache/shtdocs/$DATED.access_log.html
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}'
/var/log/httpd/error_log >
/usr/local/apache/shtdocs/$DATED.error_log.html
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}' /var/log/maillog
> /usr/local/apache/shtdocs/$DATED.maillog.html
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}' /var/log/messages
> /usr/local/apache/shtdocs/$DATED.messages_log.html
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}' /var/log/secure >
/usr/local/apache/shtdocs/$DATED.secure_log.html
/usr/bin/perl -e 'for(reverse<>){s/\n/<br>\n/;print;}'
/var/log/httpd/ssl_request_log >
/usr/local/apache/shtdocs/$DATED.ssl_request_log.html
/bin/chmod 644 /usr/local/apache/shtdocs/*log.html
/bin/chown apache:apache  /usr/local/apache/shtdocs/*log.html

Then a perl cgi script to create a html page to view the log files.

#!/usr/bin/perl
use strict;
use CGI qw(:standard);
my @logs = `cd /usr/local/apache/shtdocs/;ls *log.html`;

print header;
print start_html( " Logs" );
print h1( "Log Listing" );
   foreach my $link (@logs) {
   chomp($link);
   print "<A HREF=\"/$link\">$link</A><BR>";
   }

print end_html;



More information about the LUAU mailing list