Polls

Topics

HTTP 500 error when I run my Perl script

Posted by Vivek on Saturday January 21, 06 @2:01 am

At my work place, we provide shared hosting and http 500 error is the most common in trouble tickets. Although everything is properly configured we still get reports of error.

Send MIME type

99% time - it was not servers fault at all. I found that the most common reason for HTTP 500 errors is not printing the MIME type before outputting data to the web browser. All you need following line before outputting data to the web browser:

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

Perl does not automatically generate HTML. Also try following few suggestions:

Permissions

You need to setup file permissions on perl script

chmod  755 perlscript.pl
chmod  +x perlscript.pl

Perl script location
It must be in cgi-bin directory (or directory configured to run perl). Some servers are configured to run your CGI scripts anywhere.

Error log file

Please check your log file to find errors in your Perl script.

tail -f /var/log/httpd/error.log
tail -f /var/log/httpd/access.log

Debug

Pass -wc option to perl script at shell prompt, enter:

perl -wc myscript.pl

It will often point out exactly where the trouble is.

I am not perl guru but as a sys admin, I need to look after this kind of problems. What other techniques all of you follow to troubleshoot Perl http 500 error problem?

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or full RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in...

Discussion on This Article:

  1. Anonymous Says:

    Was browsing your site for something else I found this post. I can say use the CGI Perl module. It is more easy and you can avoid error 500. See CGI.pm doc @ here or
    here

  2. ft Says:

    I suggest include the following line at the top of your perl script:

    #!/usr/bin/perl –w

    just my 2 cents

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

~ Last updated on: June 13, 2007

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.