PDA

View Full Version : Script displaying on web page....no fixes found on this forum


dave983
02-11-2007, 11:10 PM
I'm new to PERL-CGI and am trying to use an HTML form to print out a PERL script. However, the PERL code is printing to the screen.

The simplest of PERL scripts, name websurvey2.cgi:

#!/usr/bin/perl

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

print "Hello, world";

HTML code:

<HEAD>
<TITLE>Example using FORMS</TITLE>
</HEAD>
<BODY BGCOLOR=white>

<FORM NAME=mysurvey ACTION="/usr/local/apache2/cgi-bin/websurvey2.cgi" METHOD="post">

Enter anything and click submit:<br>

<INPUT TYPE="text" size=40 NAME="favoriteurl" VALUE=""><BR><BR>

<CENTER>
<INPUT TYPE="submit" VALUE="SUBMIT">
</CENTER>
</FORM>
</BODY>


Output to the browser:


#!/usr/bin/perl

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

print "Hello, world";

KevinADC
02-12-2007, 12:57 AM
this looks like a machine path instead of a url:

/usr/local/apache2/cgi-bin/websurvey2.cgi

if the html page is in the web root, try:

cgi-bin/websurvey2.cgi

dave983
02-12-2007, 01:14 AM
When I change to cgi-bin/websurvey2.cgi I get the following error:

File not found

Firefox can't find the file at /home/andy/cgi-bin/websurvey2.cgi.

FishMonger
02-12-2007, 05:46 AM
No, it's not a path related isssue. Since it's displaying the source code instead of executing the script, it's a permission issue. Although, normally, you'd use relative instead of absolute paths.

Verify that the permissions on the script are set correctly; it should be set to 755 (-rwxr-xr-x). Are you able to execute other cgi scripts within that directory? If not, then you should also verify the apache config to make sure that the scriptalias for that directory is configured correctly.

ralph l mayo
02-12-2007, 07:28 AM
*redacted something stupid* :]

dave983
02-12-2007, 02:01 PM
I had changed the permissions a couple of times to be sure they were set to 755. Sounds like I have an Apache issue. I'll check the scriptalias. Thanks for the help.

FishMonger
02-12-2007, 06:58 PM
Another thing to check is the shebank line. Make sure that it is on line 1 of the script and that the path to perl is correct.