954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Simple log script... Use of uninitialized value in concatenation

I just upgraded my server and now a simple log script reaks of errors.

#!/usr/bin/perl
use CGI ':standard';
use warnings;

$database = "/full_path/filename.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;
}


When using SSH to get the error, it spits out

Use of uninitialized value in concatenation (.) or string at ebaylogs.cgi line 10.
Use of uninitialized value in concatenation (.) or string at ebaylogs.cgi line 10.
Use of uninitialized value in concatenation (.) or string at ebaylogs.cgi line 10.
Use of uninitialized value in concatenation (.) or string at ebaylogs.cgi line 10.

like it now can't recognize the $ENV stuff. I try to upgrade it to strict...

#!/usr/bin/perl
use CGI ':standard';
use strict;
use warnings;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

my $database = "/var/www/vhosts/cmgscc.com/httpdocs/craigslist/ebaylogs.shtml";

my $REMOTE_ADDR = "$ENV{'REMOTE_ADDR'}";
my $scripturi = "$ENV{'SCRIPT_URI'}";
my $HTTP_USER_AGENT = "$ENV{'HTTP_USER_AGENT'}";
my $HTTP_REFERER = "$ENV{'HTTP_REFERER'}";


my $shortdate = `date +"%D %T %Z"`;
chop ($shortdate);
    open (DATABASE,">>$database");
        print DATABASE "$REMOTE_ADDR - $shortdate - $scripturi - $HTTP_USER_AGENT<!-- - $HTTP_REFERER--><BR>\n";
    close(DATABASE);

{
   print "Content-Type: text/html\n\n";
print <<EOM;
<PRE>
</PRE>
EOM
   exit;
}


and it also does the same thing. Only the date goes through.

Nintendo
Newbie Poster
2 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

chmod'ing all folders 777, back to the domain does it. For example, two folders and a file...

httpdocs/folder/file.shtml

and it then works.

Nintendo
Newbie Poster
2 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: