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?
 
dperdueConnect With a Mentor Commented:
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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
 
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
 
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
All Courses

From novice to tech pro — start learning today.