Web Hosting Talk







View Full Version : I am confused problem with perl


Coolraul
10-18-2004, 02:05 AM
Not sure what the answer to this one is, but it seems like my server does know how to handle .pl files with apache.

I have a file called test2.pl, all that is in it is:

#!/usr/bin/perl

print "HELLO";

When I try to run it I get:


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

Please contact the server administrator, webmaster@xxxxx.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.31 Server at www.******** Port 80

The server is a P4 2.8 2gb ram (cant see how hw would matter but just giving the info) running FC2

Linux xx.xxxx.com 2.6.8-1.521 #1 Mon Aug 16 09:01:02 EDT 2004 i686 i686 i386 GNU/Linux

It is running WHM 9.9.0 cPanel 9.9.1.

I have the distinct impression I am missing something obvious but for the life of me I can't think of it.

I have this in the error log:

malformed header from script. Bad header=HELLO: /home/xxxxx/cgi-bin/test2.pl.

Customer swears it works on the server he is converting it from.

Any help would be appreciated.

darksoul
10-18-2004, 03:37 AM
You forgot to print the headers

#!/usr/bin/perl

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

SmartActive
10-18-2004, 04:25 AM
Hi,

Also you have to change the permissions .

chmod 755 file.pl

Regards,

Coolraul
10-18-2004, 03:20 PM
Thanks guys. Will try both suggestions. I am pretty sure that the file is 755 but will doublecheck.

Sheps
10-18-2004, 03:25 PM
You definately need the headers if you are running it from Apache.

lwknet
10-18-2004, 08:28 PM
1) chmod 0755 /path/to/your/script.pl
2) make sure your script has print "Content-type: text/html\n\n"; header
3) test it in shell first by "/path/to/your/script.pl" or "perl /path/to/your/script.pl"
4) run in apache with the "-w" flag in the shebang line so that "#!/usr/bin/perl -w"

Coolraul
10-20-2004, 03:52 AM
Just wanted to say thanks guys. The headers was the trick. Apparently this script didnt work at his old hosting providers page and I don't know perl.

Appreciate the help.