Parse::Syslog looks like a good start. Unfortunately, I have no experience with this. So I couldn't tell you how well it works.
| [reply] |
It's not clear what you're asking for help with. What part do you not know how to proceed with? Converting a text file to HTML? Having a CGI script perform the conversion? Automating the conversion?
As to the first, if you're satisfied with the logs being displayed as plain text in a fixed width font, just slap a <pre> at the beginning and a </pre> at the end, with the usual HTML boilerplate around it, and it's converted into HTML and you're done. There are also a bazillion ways to parse the lines' contents and reformat them.
| [reply] |
I believe you also need to encode at least &, <, and >. You can do this with a simple s///g or with something like HTML::Entities (part of HTML-Parser).
| [reply] |
| [reply] |
if your problem is the HTML generation you can use AnyData::Format::HTMLtable for that, it write HTMLTable for you from a single Hash. It would works perfectly in conjunction with Parse::Syslog as mention by b10m which return Hash ref.
HTH
| [reply] |
You need to remember that the CGI script is run with the uid of the apache, not as yourself. You will need to make sure that the cisco log is accessible to the apache user id (normally httpd, apache, etc).
Save the following script to the cgi-bin directory of your webserver as view_cisco_log.cgi, and modify the path to point to the actual location of the cisco log on your machine.
#!/usr/bin/perl -w
use strict;
use CGI;
use IO::File;
my $f = new IO::File "/opt/cisco/cisco.log", "r" or die;
my $cgi = new CGI;
print $cgi->header, "<HTML><TITLE>CISCO LOG</TITLE><BODY><PRE>";
while (defined (my $line = <$f>)) {
$line =~ s/&/&/g;
$line =~ s/</</g;
$line =~ s/>/>/g;
print $line
}
print "</PRE></BODY></HTML>";
And create a link on your webpage to point to the following location: http://your.website.com/cgi-bin/view_cisco_log.cgi. So that when a user clicks on the link, he/she will invoke the CGI script and see the cisco log.
| [reply] [d/l] |
Thank you. This is the way I did it and it works beutimuslly. Thanks again.
| [reply] |
# Available as URL http://www.your.domain/cisco_log.txt
#
cp $CISCODIR/log.log $WWWDIR/cisco_log.txt
Of course, there remains the questioin of whether you want everyone to know what is on your machine, or might it be better to have some security control over who can see the file.
--
TTTATCGGTCGTTATATAGATGTTTGCA
| [reply] [d/l] |
| [reply] |