Perl Problem

They have: 5,633 posts

Joined: Jan 1970

I recently setup a Linux server with Redhat 6.2, Apache, and Plesk Server Administration software. Plesk automates specific aspects of the server such a user management, email accounts, etc (www.plesk.com).

Basically I’m having trouble getting Perl to function correctly. It’s installed and scripts work absolutely fine from the prompt (a couple even function correctly from the web) however the majority error out when accessed from the web.

The error Apache is showing is:

[error] [client xxx.xxx.xxx] Premature end of script headers: /path/toscript/script.pl failed to open log file fopen: Permission denied

It’s odd as a couple scripts function fine well others won’t. All the basic stuff has been checked (scripts are upload in ASCII, path to perl is correct, CHMOD 755, etc). I’ve even tried uploading the same scripts to a few other UNIX hosts and they work fine. The main script I’ve been using for testing is simply a “Hello World” test script so it’s not a problem with the script. I’ve also tried other scripts.

Any ideas would be greatly appreciated. The "failed to open log file" error seems to be the best trouble shooter I’ve located.

Thanks,

Justin S's picture

They have: 2,076 posts

Joined: Jun 1999

Well you've probably checked this, but is the permissions of the file you're trying to open setup correctly?

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Well the web ones need to have

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

if they do, check your permissions. Also, put a -w after yer shabang...

#!/usr/bin/perl -w

Might give you some better reasons in yer log file.

Then check the permissions, like Justin said.

Some people disagree with me, but I have had a few scripts give me that error until I put in the html headers...

Bleh

Make sure they are there, and correct.

Other then that, I don't know what else to say, besides checking the syntax by running the scripts in command line and using the perlchecker (-c)

perl script.pl -c

This will tell if the syntax has some errors.

Hope that helps.
VulKen
Perl makes me wanna hurl

Pimpin like a pimp with an electrofied pimpin machine!

They have: 5,633 posts

Joined: Jan 1970

The point I was trying to convey in my first post was that it’s not a problem with the scripts. I’m by no means a Perl export but I’m positive it’s not the scripts.

Anyone know of any configurations or installation errors that may cause a problem like this?

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

If you notice the error apache is printing out.

/path/toscript/script.pl

That is why it is spittin out errors. Look for that line in your script and change it to the real path to your script.

And chmod the folder it's in too.

VulKen
To be the best, you must keep getting better

Pimpin like a pimp with an electrofied pimpin machine!

They have: 5,633 posts

Joined: Jan 1970

In terms of the Apache error log example I showed. That was simply an example of what the error log is printing. In the real log there’s a complete path to the script.

Well I appreciate the suggestions I’ve been through all the basics a hundred times. This problem is beyond the actual script and has something to do with the installation or configuration of Perl, which is why it’s in this category not CGI & Perl Help Forums.

I’ve looked around Perl’s site and haven’t found any situations like this. What configuration error would cause ALL scripts to run fine from the prompt but to error from HTTP?

Thanks,

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.