Unable to exec perl cgi's from url

Made this worth 250 points since I need an answer soon.

I have linux mandrake 6.1 and all i'm trying to do is have a perl cgi execute when I access it from a url.

e.g.:  http://mywebserver/test.pl

I want it to return the html output from that perl script.

instead, what i get is:

--
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root@localhost 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.
---

the perl script executes fine from the linux prompt.  any ideas?  

thanks!
dave
LVL 1
davekoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

barreroCommented:
have you seen the error log file, to see exactley what is the perl script printing out?
normally it is on /etc./httpd/logs and the file has some name with the -error.log extension... look on it...
0
cgreyCommented:
Have you checked the permissions (mode 0555) for cgi-bin scripts as well as ownership of the file? And also, try changing the extension to .cgi instead of .pl. Some of the default installations don't allow .pl to execute by default, only .cgi. Just be sure to use the hashbang for your perl binary (#!/usr/bin/perl or whatever).
0
finikCommented:
to cgrey:
The cgi vs. pl issue is irrelevant, since if apache wouldn't know that "pl"
should be executed, it would just show
the source in the browser and not return
internal server error.

barrero is right, the right place to check is:
/etc/httpd/logs/error-log
in case of standard RH-like RPM apache
installation and possibly
<prefix_you_provided>/www/error_log in case of apache installed from original source.

My bet is you forgot to print the right
header from the CGI, and you will find
an error in error_log telling you this.
In this case you should do this:

use CGI;
print $query->header('text/html', '200 OK');
(in case of HTML output, for example).

Another issue that usually causes the problem is the permissions of the data files that the CGI reads. Since CGI is run as nobody, all the files should be readable by nobody as well.

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

finikCommented:
Oops, as you understood, I forgot this line after th "use CGI;":
$query = new CGI;
0
davekoAuthor Commented:
OK.  I did check the log and it did point to the header as being bad.  What is the proper convention for specifying an error page to be returned?

For example, how do I specify a 400 - Bad Request while providing my own test for the reason?
0
dperdueCommented:
I don't think that you would want this to be possible, it would be a huge security risk. usually, you would access an html file and allow the user to interact with that page and let the web server handle running perl scripts.
The results of the Perl script would be sent back to the browser in HTML ususally. Issuing the command directly from the browser doesn't really give you any format to present the results back to you.
There is a way to telnet into the web server and issue html commands to the server and get back the html that would be sent to the browser. I'm not going to have access to my Linux box since I'm out of town for a while, but any good CGI book should be able to give you those commands.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
finikCommented:
Just:
print $query->header('text/html', '404 File Not Found');
instead of the '200 OK' or whatever http code
you want. Just do it same way. You put in the header the http code, 200 or any other error, and after the header, you can send any html
text you want. Netscape shows it for sure, MSIE doesn't as far as I know, it shows some
predefined, and not informative at all his won pages.

dperdue is right
about the security leak you may be inserting here, if you won't code it properly and cover all holes. However, I don't see the reason, why dperdue locks the question by answering it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.