Click to See Complete Forum and Search --> : Internal Server Error


Vahagn
04-04-2005, 07:23 AM
Anyone who knows why a PERL script on a server results in "Internal Server Error"
if I have an active FTP or SSH session connected to the account? I'm aware of the fact that
the server might be configured in order to block execution while there is an active session,
but the problem is that I have another site at the same server, written in the same way,
and it works fine even when there is an active FTP session. I can not figure out how the
second code is different in implementation than the first one....

Another odd thing is that the pages occasionally result in "Internal Server Error", but if
you reload them they work! It's really irritating, since if there was an error in the script
it would fail all the time but now it appear sporadic and I can not understand what this
depends on.

Anyone out there who can give a hint about what might be causing this two kind of
errors?

Thanks in advance,

/V

Jeff Mott
04-04-2005, 07:30 PM
The first thing to do is to add this line to your code.use CGI::Carp qw[fatalsToBrowser];This will print the real error message to the screen instead of the generic server error message.

Next, that the script works sometimes and fails others. Does the script attempt to access any outside resource? That is a file, database, network connection, anything? If so then check to make sure that resource will work properly for every execution.

If none of that helps then you'll have to post your code with more specific details to what is failing.

Vahagn
04-05-2005, 01:49 AM
Thanks for the hints!

If you mean external resources which our on other servers or sites: Noop! But we use our own database on the same server (textfiles from which we genarate pages) and also use CSS-files from the HTML directory (CGI resides under /cgi-bin/ while the HTML is under /htdocs/) which we include in each page. But that should hardly be the cause, would it?

I'll try the CGI::Carp to see if I can see what really happens.

Thanks a lot and I'll come back with the result.

/Vahagn

winged1
04-05-2005, 08:41 AM
attempting to access a 'not found' file or directory can give you the error.

Vahagn
04-05-2005, 08:51 AM
Well, I wish that it was that simple! I tested to have only a simple HTML page containing two different IFRAMES, each calling to its separate PERL script which just printed some line. Nothing fancy (no database, no remote call, no reading. NADA!) But as soon as a FTP session was active => "Internal Server Error!"!!!

And even in the case of the occasional errors, the page works if you reload it so the source is there, the data is OK, but it sometimes gets error and sometimes work!!! That's why it bugs me most of all.

The provider's limit of maimum 5 concurrent executing PERL processes is the most logical thing that I can think of, but according to them that's not the reason.

Anyone who knows what number the providers usually set this limit to? Doesn't Five sound to low?

winged1
04-05-2005, 09:55 AM
I'm not sure if it would cause the error, but if it's a timeout issue, your hoster may simply be underpowered. Does your hoster provide a forum that you could see if others on the same service are having a similar problem.

Vahagn
04-05-2005, 11:42 AM
OK, I added the "use CGI::Carp qw[fatalsToBrowser];" but doesn't seem to make a differance and I don't see no info.

I read the errorlog and what happens is:

"Premature end of script headers: xxxxxxx.cgi"

I searched for the error on the net and saw couple of explainations, but can't see how that refers to my script. Mine looks like this:


#!/usr/local/bin/perl

#use CGI::Carp qw[fatalsToBrowser];

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

if ($ENV{REQUEST_METHOD} eq "GET"){
$query_string = $ENV{QUERY_STRING};
}
elsif ($ENV{REQUEST_METHOD} eq "POST"){
sysread(STDIN, $query_string,$ENV{CONTENT_LENGTH})
}
else {
print("unsupported request type \"$ENV{REQUEST_METHOD}\"");
}

($language, $thisRubrik) = split("=", $query_string);

$html = "<BASE href=\"http://MYOWNDOMAIN.COM/\">\n<HTML>\n";

$html .= "<head><link rel=\"stylesheet\" href=\"includes/styles.css\" type=\"text/css\"></head>\n";

$html .= "<BODY leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" BGCOLOR=\"#FFFFFF\">\n";

$html .= "<table width=\"100%\" cellspacing=5 class=\"table-bg\">\n";

$html .= "<tr>\n<td class=\"content\">\n";

$html .= "&nbsp; &nbsp; TEXT GOES HERE!<br></td>\n</tr>\n\n";

$html .= "</table>\n</BODY>\n</HTML>\n";

print "$html";



What can go wrong in here?!

Jeff Mott
04-05-2005, 02:09 PM
OK, I added the "use CGI::Carp qw[fatalsToBrowser];" but doesn't seem to make a differance and I don't see no infoI'm assuming you had it uncommented when you were testing it out? (The rest of the code could be cleaned up a bit. See the sticky Learn Perl and CGI with 'Beginning Perl' (http://www.webdeveloper.com/forum/showthread.php?t=50014) for more information about programming in Perl.)

Try the most basic of scripts.#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print 'Hello, World!';If this suffers from the same problem then the issue is not with the code of the script, it is with the host in some way.

dancefix
04-08-2005, 09:41 AM
I'm new to Perl myself, but your line:

sysread(STDIN, $query_string,$ENV{CONTENT_LENGTH})

could be missing the semi-colon at the end.

You could also change

#!/usr/local/bin/perl
to
#!/usr/local/bin/perl -w

maybe the error log will then show more specific errors.

Also make sure you are uploading the file as ASCII.

leocharre
04-15-2005, 10:02 PM
Two things. One, use this for fatals to browser:
BEGIN {
$|=1;
use CGI::Carp('fatalsToBrowser');
}

The other thing, why don't you ssh into your account and try running there, might be more helpful.
most providers should let you access your account on box-
if you're on linux, open terminal and use this command
$ssh -lusername domainwithouthttp.com
example: ssh -ljoeschmoe thedump.com
use your normal ftp password.
you should be in your account home, not webshare or html public..
do a listing
$lsgo to where your script is.. and run it
$perl yourscript.cgi
the output should be more informative.
Here you can also use vim to edit and debug. Much better then uploading etc etc.. ugh.. :)

Jeff Mott
04-16-2005, 10:26 AM
One, use this for fatals to browser:
BEGIN {
$|=1;
use CGI::Carp('fatalsToBrowser');
}There is no need to set autoflush. Simply useing the module is sufficient.

I'm new to Perl myself, but your line:
sysread(STDIN, $query_string,$ENV{CONTENT_LENGTH})
could be missing the semi-colon at the end.In this case it is actually ok, only because that statement is the last one within a block.