I just upgraded servers, and I'm now on 'perl, v5.8.8 built for i386-linux-thread-multi' and a simple log script doesn't work. I got it changed to...
Code:
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $cgi = CGI->new;
my $database = "/full_path/file.shtml";
my $shortdate = strftime("%m/%d/%y %H:%M:%S %Z", localtime);
my $remote_addr = $ENV{'REMOTE_ADDR'} || 'N/A';
my $script_uri = $ENV{'SCRIPT_URI'} || 'N/A';
my $http_user_agent = $ENV{'HTTP_USER_AGENT'} || 'N/A';
my $http_referer = $ENV{'HTTP_REFERER'} || 'N/A';
print $cgi->header, $cgi->start_html;
warningsToBrowser(1);
print $cgi->p("$remote_addr - $shortdate - $script_uri - $http_user_agent<!-- - $http_referer-->");
open my $dbhandle, '>>', $database
or die "failed to open '$database' for appending: $!";
print $dbhandle "$remote_addr - $shortdate - $script_uri - $http_user_agent<!-- - $http_referer--><BR>\n";
close $dbhandle;
where it only recognizes the time. It doesn't recognize any of the $ENV stuff. It spits out
N/A - 05/25/10 10:53:14 PDT - N/A - N/A - N/A
in to the log file. It only does logging when accessed via SSH, and does nothing when called from the script. (Script spits out the ISE message.)
The original script that worked fine before the server upgrade...
Code:
#!/usr/bin/perl
use CGI ':standard';
use warnings;
$database = "/full_path/file.shtml";
$shortdate = `date +"%D %T %Z"`;
chop ($shortdate);
open (DATABASE,">>$database");
print DATABASE "$ENV{'REMOTE_ADDR'} - $shortdate - $ENV{'SCRIPT_URI'} - $ENV{'HTTP_USER_AGENT'}<!-- - $ENV{'HTTP_REFERER'}--><BR>\n";
close(DATABASE);
{
print "Content-Type: text/html\n\n";
print <<EOM;
<PRE>
</PRE>
EOM
exit;
}
Does any one know how to get one of those versions working?