Forum Moderators: coopster & phranque

Message Too Old, No Replies

Dreaded Internal Server Error running .pl script

         

MrDOS

11:14 pm on Jan 27, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hi again! Thanks for all who helped with my last post. I am very close to getting all of this legacy perl code working.
I am able to get simple .pl scripts to run in the browser, but some of the more complex ones result in "Internal Server Error."

My first troubleshooting step was to run the complex scripts from the bash prompt, and they run OK. In fact, if I redirect the output to an html file, the results look correct in the browser:
$ perl -w scriptname.pl > test.html

Does anyone have any suggestions on where I can look next? I am not getting any errors about missing libraries.

Thanks!

phranque

12:06 am on Jan 28, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



whenever there is an "Internal Server Error" (aka 500 status code in the response) there should be an entry in the server error log associated with that response.

find the time stamp for the entry logging your scriptname.pl request/500 response in your server access log and then look for error log entries with the same time stamp.

MrDOS

12:25 am on Jan 28, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



That was helpful, thanks.

The httpd error_log shows:
AH01215: install_driver(ODBC) failed: Can't locate DBD/ODBC.pm in @INC
When I try to install install DBD::ODBC from cpan, it says that it is already up to date.
I also tried copying the ODBC.pm to a folder that exists in @INC, but no luck thusfar.

I am not sure how my configuration is out of whack, as I reinstalled everything from scratch on a fresh VM. I am curious as to why @INC shows 7 folders, some of which do not even exist. I suspect I have configurations distributed among several of these folders.

My error_log shows:

@INC contains:
/usr/local/lib/perl5/site_perl/5.26/i686-cygwin-threads-64int
/usr/local/share/perl5/site_perl/5.26
/usr/lib/perl5/vendor_perl/5.26/i686-cygwin-threads-64int
/usr/share/perl5/vendor_perl/5.26
/usr/lib/perl5/5.26/i686-cygwin-threads-64int
/usr/share/perl5/5.26
/opt/dbamon/lib

What folder is searched first? Does it go top to bottom, or bottom to top?

Thanks.

phranque

1:54 am on Jan 28, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What folder is searched first? Does it go top to bottom, or bottom to top?

it's not a stack, it's a list so it goes first to last.
"/usr/local/lib/perl5/site_perl/5.26/i686-cygwin-threads-64int " is first.

tangor

10:54 pm on Jan 28, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Somewhere in the "complex script" a call is incorrect, most likely a path, and probably a path that looks perfectly okay ... but since it came from a different server to a new server might not have the same subpaths (been there, done that, nightmare!).

typomaniac

6:53 am on Jan 29, 2019 (gmt 0)

10+ Year Member Top Contributors Of The Month



I had to make a change to a perl script and with the exception of minor changes like which db tables to call was pretty much a copy paste. Hadn't messed with any perl for a while and when the big 500 appeared all I could think was ? Sometimes its something simple like a missing content tag, like print" Content-type:text/html\n\n";

MrDOS

6:30 pm on Jan 31, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hi again. I am a little closer to understanding what is going on. I am able to get any of my complex .pl scripts to work from a bash prompt by redirecting the output to a .html file. The .html file looks great in the browser.
However, I get errors like "AH01215: Can't locate DBI.pm in @INC" running the same scripts in the browser. I have tried using push to add paths to @INC. @INC gets updated OK I run the .pl script from bash, but the push does not change @INC when running the same .pl script in the browser (?).

From the bash prompt, I can see the path and am able to see that DBI.pm is installed OK using:
$ perldoc -l DBI
/home/svc_SQL_dbmsmon/perl5/lib/perl5/i686-cygwin-threads-64int-multi/DBI.pm
When I place
system("perldoc -l DBI > DBILocation.txt");
in a test.pl script, and visit the script in the browser, the httpd error_log shows:
AH01215: No documentation found for "DBI".: /srv/www/cgi-bin/test.pl

Any thoughts on where I can look next? TIA

phranque

12:28 am on Feb 1, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



how are you running perl under apache? (i.e. mod_perl? CGI?)

perhaps you will need to specify a PERL5LIB environment variable in your server config or .htaccess using a mod_env directive.

MrDOS

12:40 am on Feb 1, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



Thanks again for your assistance. To compare the environments, I saved the results of env from the bash promt, and from running the .pl script in the browser. This allowed me to see further what was not working when running from the web page, and I set the PERL5LIB env variable, as you suggested.
I never determined why I couldn't push my desired folder to @INC -- but I got everything to work by copying all contents (including subdirs) that didn't already exist from the "correct" folder (/home/svc_SQL_dbmsmon/perl5/lib/perl5/i686-cygwin-threads-64int-multi/DBI.pm) to one of the existing folders that appears in @INC (/usr/share/perl5/5.26). I hated to do this kludge without understanding more, but I am a bit fried from working in such a foreign environment.

Perhaps I will come back fresh another time, but for now, I can return to my "regular" job!

phranque

1:22 am on Feb 1, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



it may have something to do with perl running in taint mode:
https://perldoc.perl.org/perlsec.html#Taint-mode-and-%40INC