Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 500: Can't Replicate It

Status
Not open for further replies.

mtorbin

Technical User
Nov 5, 2002
369
US
Here's the error:

Code:
Use of unititialized value in -3 at line 11

Here's the line:

Code:
$currentFolder =~ s/\%20/ /gi unless (-e $currentDirectory);

and Here's the full code:

Code:
#!/usr/bin/perl -wT
use integer;

print "Content-type: text/html\n\n";

my $currentFolder = $ENV{"QUERY_STRING"}?substr($ENV{"QUERY_STRING"},17):"";
my $currentDirectory;
my $length = length($currentFolder);

if ($length > 0) {
    $currentFolder =~ s/\%20/ /gi unless (-e $currentDirectory);
    $currentDirectory = "/var/[URL unfurl="true"]www/html/ftpfiles"[/URL] . $currentFolder . "/";
}

else {
    $currentDirectory = "/var/[URL unfurl="true"]www/html/ftpfiles/";[/URL]
}

opendir (FTPDIR, $currentDirectory) || dienice($!);


sub dienice {
 print "<div style=\"color:red;\">Error ",$_[0],"</div>";
 print $currentDirectory;
 exit;
}


my @folderContents = readdir (FTPDIR);
closedir (FTPDIR);

print <<"HTML code";
<html>
<head>
<title>Untitled Document</title>
<link href=../ftpStyle.css rel=stylesheet type=text/css>
<script src=../jsLibFTP.js></script>
</head>
<body>
<table width=100%  border=0 cellspacing=2 cellpadding=0>
<tr align=left valign=top>
<td width=2%><a href=../cgi-bin/listFiles.cgi><img src=../images/icon_arrowPrev.gif width=20 height=22 border=0></a></td>
<td width=98%><a href=../cgi-bin/listFiles.cgi>Return To Main Directory</a></td>
</tr>
</table>

<table width=80% border=0 align=center cellpadding=0 cellspacing=0>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_gray_corner_tl.gif width=19 height=20></td>
<td background=../images/box_gray_side_t.gif><img src=../images/box_gray_side_t.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_gray_corner_tr.gif width=19 height=20></td>
</tr>
<tr align=center valign=top>
<td background=../images/box_gray_side_l.gif><img src=../images/box_gray_side_l.gif width=19 height=2></td>
<td bgcolor=#f2f2f2>
<table width=100%  border=0 cellspacing=5 cellpadding=0>
<tr valign=top>
<td width=3% align=center>&nbsp;</td>
<td width=70% class=tableHeader>Name</td>
<td width=17% class=tableHeader>Date</td>
<td width=10% class=tableHeader>Size</td>
</tr>
<tr valign=top>
<td align=center><img src=../images/icon_folderOpen.gif width=27 height=22></td>
<td><b>$currentFolder</b></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
HTML code

if (@folderContents) {
   foreach my $indivFile (@folderContents) {
       next if $indivFile=~m/^\.+$/;
       my $fullUnit = $indivFile;
       # escape the following "."
       my ($name, $extension) = split (/\./ , $indivFile);
       
       if ($extension) {          
           my $adjustedLink = $fullUnit;
              
           ## my @info = stat("/var/[URL unfurl="true"]www/html/ftpfiles/$fullUnit");[/URL]
           
           my $funkyChicken = "/var/[URL unfurl="true"]www/html/ftpfiles".[/URL] $currentFolder . "/" . $adjustedLink;
           
           my @info = stat($funkyChicken);
           
           $adjustedLink =~ s/ /\%20/gi;
           $currentDirectory =~ s/ /\%20/gi; 
           
           my $biteSize = $info[7];
           my $fileSize = $biteSize/1024; 
           
           @date=localtime $info[9];
           $date[5]+=1900; $date[4]++;
           
           $extension = lc ($extension);
           
           print "<tr valign=top>\n";
           print "<td align=center><img src=../images/icon_" . $extension . ".gif width=18 height=22></td>\n";
           print "<td><a href=fileDownload.cgi?fileName=" . $currentDirectory . $adjustedLink . ">$fullUnit<a></td>\n";
           print "<td>";
           printf "%02d/%02d/%04d %02d:%02d:%02d",@date[4,3,5,2,1,0];
           print "</td>\n";
           print "<td>" . $fileSize . "k</td>\n";
           print "</tr>";
       }
       
       else {
           my $adjustedLink = $fullUnit;
           $adjustedLink =~ s/ /\%20/gi;
           $currentFolder =~ s/ /\%20/gi;
           $adjustedLink = $currentFolder . "/" . $adjustedLink;
           
           print "<tr valign=top>\n";
           print "<td align=center><img src=../images/icon_.gif width=20 height=22></td>\n";
           print "<td><a href=listFiles.cgi?currentDirectory=" . $adjustedLink . ">$fullUnit<a></td>\n";
           print "<td>---</td>\n";
           print "<td>---</td>\n";
           print "</tr>";
       }
   }
 }

print <<"HTML code";
</table>
<br>
<br>
</td>
<td background=../images/box_gray_side_r.gif><img src=../images/box_gray_side_r.gif width=19 height=2></td>
</tr>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_gray_corner_bl.gif width=19 height=20></td>
<td background=../images/box_gray_side_b.gif><img src=../images/box_gray_side_b.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_gray_corner_br.gif width=19 height=20></td>
</tr>
</table>
<br>
<div align="center" class="legalText"><i>If you suspect that a file is missing or that that a specific directory/file listing is incorrect, please contact <a href="mailto:matt.torbin\@peigenesis.com?subject=FTP Site Comments">Matt Torbin</a></i></div>
<br><br>
</body>
</html>
HTML code

For the life of me, I can't replicate this error and it only happens once in awhile. Usually fixing it includes clearing the cache and cookies and then it never comes back. However, I've found one case where it happens time and time again. Unfortunately the machine is in the UK so I can't see exactly what the user is doing. Can someone help end this madness?? What if I remove the -wT, will that fix it?

Thanks,

- MT
 
I also get this error:

Code:
Can't call method "value" on an undefined value line 9

from the following code:
Code:
#!/usr/bin/perl -w

use CGI qw/:standard/;
use CGI::Cookie;
use CGI::Carp qw(fatalsToBrowser);
use perlLib;

%cookies = fetch CGI::Cookie;
my $emailCookie = $cookies{'peiEmail'}->value;
my $ipCookie = $cookies{'peiIP'}->value;

my $fileName = substr $ENV{"QUERY_STRING"},32;  ## not 9

my $fileLoc  = '[URL unfurl="true"]http://rhlwebsvr/ftpfiles/'[/URL] . $fileName;
   $fileName =~ s/\%20/ /gi unless (-e $fileLoc);
   
   ## Please note that an odd anomaly has occured with some files.  For an unknown reason.
   ## Some files do not interpret the %20 correctly.  So far we have determined files that have
   ## word fragments that begin with "De" or "Descrip" do not work and must be changed to either
   ## "description" or "dscrp" in order to work.  More on this as found.
   ## 08/25/05 Matt Torbin

my $logFileName = $fileName; 
 
my($localDate,$localTime) = createDateStamp();
my $timeStamp = "$localDate $localTime";

$logEntry = '<tr align=left valign=top><td><a href=mailto:' . $emailCookie . '>' . $emailCookie . '</a></td><td>' . $ipCookie . '</td><td>' . $timeStamp . '</td><td>' . $logFileName . '</td></tr>' . "\n";

open (LOG, ">>ftpLog.txt") or die "file cannot be opened.";
flock (LOG, 2);
print LOG "$logEntry";
close (LOG);

print "Content-type: text/html\n\n";
print '<html>';
print '<head>';
print '<title>File Download In Progress</title>';
print '<link href=../ftpStyle.css rel=stylesheet type=text/css>';
print '<script src=../jsLibFTP.js></script>';
print '</head>';
print qq(<body onLoad="delayDownload('$fileName')">);
print '<br>';
print '<br>';
print '<table width=300 border=0 align=center cellpadding=0 cellspacing=0>';
print '<tr align=center valign=top>';
print '<td width=19 height=20><img src=../images/box_blue_corner_tl.gif width=19 height=20></td>';
print '<td background=../images/box_blue_side_t.gif><img src=../images/box_blue_side_t.gif width=2 height=20></td>';
print '<td width=19 height=20><img src=../images/box_blue_corner_tr.gif width=19 height=20></td>';
print '</tr>';
print '<tr align=center valign=top>';
print '<td background=../images/box_blue_side_l.gif><img src=../images/box_blue_side_l.gif width=19 height=2></td>';
print '<td bgcolor=#6699CC>';
print '<h5>Your file is currently downloading...</h5>';
print '<img src=../images/progressBar.gif width=225 height=14>';
print '<br>';
print '<br>';
print 'If your file does not download,<br>';
print "please click <a href=" . $fileLoc . ">HERE</a>"; # $fileLoc will be supplied by the form.
print '<br>';
print '<br>';
print '</td>';
print '<td background=../images/box_blue_side_r.gif><img src=../images/box_blue_side_r.gif width=19 height=2></td>';
print '</tr>';
print '<tr align=center valign=top>';
print '<td width=19 height=20><img src=../images/box_blue_corner_bl.gif width=19 height=20></td>';
print '<td background=../images/box_blue_side_b.gif><img src=../images/box_blue_side_b.gif width=2 height=20></td>';
print '<td width=19 height=20><img src=../images/box_blue_corner_br.gif width=19 height=20></td>';
print '</tr>';
print '</table>';
print '</body>';
print '</html>';

If a person were to clear their cookies in the middle of this process that I've built and so the cookies are no longer there to find, would this create that error?

- MT
 
regarding the uninitialised value error

instead of checking the length() of that string, have you tried this check?

if($currentFolder){
[tab]$currentFolder =~ s/\%20/ /gi unless (-e $currentDirectory);
[tab]$currentDirectory = "/var/ . $currentFolder . "/";
}

else {
.
.
.

Mike

I am not inscrutable. [orientalbow]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Thanks, I'm in the middle of testing that now. It seems to have worked. About the error 500, I think I solved it. If the user does not have cookies enabled then you will get the error 500. I need to build something to catch that.

- MT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top