Jump to content

[Answered] Diagnosing Perl Cgi Errors


Recommended Posts

Am stuck trung to diagnose what is wrong with my perl CGI. A simpel port from a previous host, so I try say a simple Perl script that prints a list of variables:




and the error I receive is:


Internal Server Error

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

Please contact the server administrator, webmaster@bernd.wechner.info 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/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/0.9.8e-fips-rhel5 mod_mono/2.6.3 mod_jk/1.2.35 FrontPage/ mod_bwlimited/1.4 mod_auth_passthrough/2.1 mod_wsgi/3.4 Python/2.7.4 Server at bernd.wechner.info Port 80


And yet in my error log I see only a failed access attempt to:


[Tue May 12 14:30:16 2015] [error] [client] File does not exist: /home/bwechner/public_html/bernd/500.shtml


which makes sense as Ithe reported error says as much.


Now the script has mode 0755 as needed and it resides in the cgi-bin fold which laso has 0755 mode.


The access log correctly shows: - - [12/May/2015:14:30:16 -0700] "GET /cgi-bin/printenv.pl HTTP/1.1" 404 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"


And the favicon displays on my browser tab.


Is there a way to further diagnose why a very simple perl CGI would throw a 500 error? Here's all it contains:




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


foreach $key (keys %ENV) {

print "<li>$key: $ENV{$key}";



Any help would be deeply appreciated.
Link to comment
Share on other sites

  • 2 weeks later...

Thanks Byron! Will try. As soon as I can log back in. Something seems up with my account or with Johnny, Looking into it now.

Link to comment
Share on other sites

  • 5 weeks later...
Define your first line of code (shebang line) like this
#!/usr/bin/perl -w


Finally got to log on again added -w to the first line and voila it works. Thanks enormously Byron.


The irony is that -w only turns on warning reports and yet adding it seems to stop the script from bailing as well, i.e. it seems it bails on warnings without it causing the error. Must check the warnings, perhaps in the log file, when I get around to it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...