We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Ubuntu LAMP Perl Errors

Medium Priority
454 Views
Last Modified: 2013-12-16
We are currently trying to move a website from an IIS server to an Apache one, and are having trouble with some of the perl scripts.

We get the following error when the site calls the perl script:
The server encountered an internal error or misconfiguration and was unable to complete your request.

There are no issues with it running in IIS, and I can also run the perl script from the command line without errors.

I see no errors in the log at /var/log/apache2/error.log that look related.
Comment
Watch Question

Top Expert 2009

Commented:
Is /var/log/apache2/error.log your error log for this server?  Are the scripts marked as executable by the web server user?  Can you run any perl scripts?  If so, are they in the same directory as the ones you can not run?

Author

Commented:
I believe this is where the logs are.  I see other errors here.
The scripts are marked as executable.  I can run test perl scripts with no issues.  They are in the same directory.
Top Expert 2009

Commented:
I'm guessing that there is something in the log that is relavant.  Try this:
    Look at the log, and not the last error
    Try running one of the scripts that does not work
    Look at the log again, and see if there are any additional errors.

If you had the scripts on a windows machine, it could be that you have windows style line endings, not unix style.  How did you transfer the files from windows to unix?  To fix, you can use the dos2unix program.  Or this perl statement:
    perl -i -pe 's/\r//g' filename.pl

Author

Commented:
I ran the perl statement and tried again.  Got these errors.

[Mon Feb 16 11:51:35 2009] [error] [client 64.246.146.231] (13)Permission denied: exec of '/home/bpiweb/Websites/site2/er_info_request/info_formmail.pl' failed, referer: http://site2.com/er_info_request/index.htm
[Mon Feb 16 11:51:35 2009] [error] [client 64.246.146.231] Premature end of script headers: info_formmail.pl, referer: http://site2.com/er_info_request/index.htm

Author

Commented:
After doin g a chmod +x to the file, the script is running.

THose errors did not exist though before I ran the perl command you gave me.

There are many perl scripts, is there a way to get this to run against all of them?
CERTIFIED EXPERT

Commented:
Using apache, perl scripts normally go in/under the cgi-bin directory, unless you've setup an alternate ScriptAlias location.

What are the permission and ownership settings of the script?
Do you have a cgi-bin directory?
Are you able to run any other perl cgi scripts?
CERTIFIED EXPERT

Commented:
chmod +x *.pl

Author

Commented:
They are all in other folders, and I was more looking for the way to do the perl command perl -i -pe 's/\r//g' filename.pl

Top Expert 2009
Commented:
If that perl command solves the problem, it means you had windows style line endings on your files.  You can use this to go through all folders:
    change to the top level directory containing your scripts
    find . -name \*.pl -type f -exec perl -i -pe 's/\r//g' {} \;

Note that if you have any files that end in .pl, this will change those - even if they aren't perl files.  

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT

Commented:
Or, you could use dos2unix

find . -name \*.pl -type f -exec dos2unix -k {} \;
CERTIFIED EXPERT

Commented:
I'm not sure if this was part of your question, but the chmod command has the -R option to change files and directories recursively.

chmod -R +x *.pl
CERTIFIED EXPERT

Commented:
I just noticed that Adam mentioned dos2unix but didn't include an example of its usage.  It should be mentioned that, in this case, dos2unix would be more efficient that the perl command.  However, if we're talking about a reasonable number of files, then you may not notice much difference.

Author

Commented:
After changing these and then rechanging the permissions to be executable all is working well.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.