PDA

View Full Version : cgi problem on linux server...


Whopub
02-28-2006, 01:56 AM
Hi,

I recently moved a site from a NT machine to a linux account. I have 2 tailor made scripts that have been running for years. They were made when I was still using unix, then I moved to a NT account and, after some tweaking, the scripts kept working.
Now that I'm back to linux I can't make them work! Server support doesn't really bother to help since the problem is on my script not on their server... You know the drill.

Anyway, I'll start with one script and then I'll explain the other later, hopefully after this first one is working.

This first script is actually very simple, or so it seems, since I don't know the first things about cgi... What it does is it creates a cookie using a validation key stored on another file.

Here's the code:

#!/usr/local/bin/perl

use strict;
use CGI qw(:standard escapeHTML -no_debug);

my $cookie = cookie ( -NAME => "pass",
-VALUE => "16f89ea150f13792242b7e79f64b1ac2",
-EXPIRES => "+2y");
print header(-COOKIE => $cookie), start_html(),p("cookie created"),end_html();

The perl path should be correct. It was indicated by the server support people.

The 'pass' file (where it gets the validation key from) is located at the exact same
dir (cgi-bin).

The cgi-bin is CHMODed to 755, and so are the script itself and the 'pass' file.

The error message I get reads the following:


500 Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.


More information...

Operating system: Linux
Kernel version: 2.6.15.4-AMDv7
Machine Type: x86_64
Apache version: 1.3.34 (Unix)
PERL version: 5.8.5
Path to PERL: /usr/bin/perl
PHP version: 4.4.1
cPanel Build: 10.8.1-RELEASE 113

The server belongs to http://www.skynethosting.net/

It's a cheap VIP account.

I'd really appreciate if any of you experts could take a look at this code and try to figure out what's wrong. It's probably basic, but I really don't know the first thing about cgi, perl, or anything besides html.

Thank you for your time.

Best regards,

Whopub

scoutt
03-02-2006, 01:34 PM
please read carefully :D

your script: #!/usr/local/bin/perl
the server: /usr/bin/perl

don't look the same to me???

Whopub
03-02-2006, 02:17 PM
Hi scoutt,

Nice catch! Unfortunately it doesn't solve the problem. I guess the info on the server specs is not correct, since I got the other path on an email from their support.

Besides, they installed a test script, just to show me that it worked, thus proving there's nothing wrong with my account, and it had the same path I'm using!

Here's the code on their test script:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "CGI IS Working Fine. :)";

So at least the path should be correct, which means something else must be causing the problem.

This is awful since I'll have the whole site offline until this is solved. Not a very smooth server change...

scoutt
03-02-2006, 02:45 PM
ok, at least we know which one to use :P. so, can you see the error.log file shows? each time you get an error like that it will rite in the log file as to what line failed. can you find that file? or ask your host. they should have at least told you where it is failing.

I am not all into perl but I think this is a module

use CGI qw(:standard escapeHTML -no_debug);

make sure they have it installed.

Tham
03-03-2006, 07:30 AM
maybe its because your print command is wrong. Try this:

print "I want to print this\n";

Maybe its that.

TrojanWarBlade
03-03-2006, 05:38 PM
Error 500 is normally when your script fails to compile on the box in question.
Do you have shell access to the machine?
Can you try a "perl -c scriptname.cgi" on it to prove it compiles on that machine?

Tham
03-06-2006, 11:15 AM
looking at your script I'd say that it is your print command that is off as I said before. Bad syntax is usually the problem with Perl.

Tham
03-06-2006, 11:16 AM
and the bad thing is, with perl you can leave out one character in a 3000 line program and it will crash. But Perl does have its benefits I guess ;-D

TrojanWarBlade
03-07-2006, 07:38 PM
Tham,
The code compiles.
Did you check that before you suggested a syntax error?

Whopub
03-08-2006, 11:32 AM
Like I said, I know nothing about this script language. This was coded by a guy I lost contact with years ago. I won't be able to test any of your suggestions unless I know exactly how they're coded and where exactly on the script they should be placed. I know nothing about this sort of syntax.

The weird thing is that this script has worked correctly on about 4 different servers, including both unix and NT, and now, all of the sudden, it can't be made to work on this new account.

scoutt
03-08-2006, 12:45 PM
can you see teh error logs? ask your server admin to show you. it will help a lot.

Whopub
03-08-2006, 02:27 PM
Scoutt: I asked them if there were any logs I could use for reference the first time you mentioned it, but they didn't address them in their reply. They just said it was obvious the server was ok, so the problem was in my script. And that was it. Not much of a support those guys... :rolleyes:

scoutt
03-08-2006, 02:45 PM
yeah, the support sucks :P cause you can see the error.log file and find the exact line it failed on. the error.log file also records script errors. each client on a host should have one.