I'm new to PHP and I have a working perl script that basically logs into remote servers, cats a log file and displays certain log file information to STDOUT.
I want to make this now viewable as a web page, hence looking at PHP to display this output. I just want to view the same output as I see on the terminal for now. The goal would be then to improve the formatting/presentation of this data.
Also, any ideas/examples on best approach to format the output via PHP would be great. Thanks!!
Here is the perl script: (executed by passing some arguments)
Usage: ./statsinfo.pl Jul 26 2010 /var/log/server.log server1
my($mon,$day,$year,$file,$server) = @ARGV;
my $regex_flag = 0;
splice(@ARGV, 0, 4, ());
foreach my $server ( @ARGV ) {
print "===================================================================================\n";
print "REPORTING SUMMARY for BACKUP SERVER : $server\n";
open(my $fh,"ssh $server cat $file |") or die "can't open log $server:$file: $!\n";
while (my $line = <$fh>) {
if ($line =~ m/.* $mon $day \d{2}:\d{2}:\d{2} $year:.*(ERROR:|backup-date=|backup-size=|backup-time=|backup-status)/) {
print $line;
$regex_flag=1;
}
} #end while loop
if ($regex_flag==0) {
print "NOTHING TO REPORT FOR $server: $mon $day $year \n";
}
$regex_flag=0;
close($fh);
}