Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic perl/cgi question

Status
Not open for further replies.

mover50

Programmer
Aug 3, 2004
77
US
I am learning perl using Ellie Quigly's book 'Perl by Example'. For the most part it has been very very helpful.
However I am stumped on how to get my perl script to work with cgi.(refering the example3.16 in the manual).

I have posted this on the Apache forum and got some response, but not to the extend that I got it resolved.
I am aslo doing this on linux (learning that too).

My basic question is;
How do it get a perl script to work with linux/cgi/apache?

The browser is Mozilla

I am not even sure what the proper suffix should be or where it should reside. Currently the path is:
/home/mover50/public_html/example.cgi

mover50 is my logon id on linux.

When I run it on my browser as:

I get a not found on this server.

If i drop the .cgi I get a display of the source code or perl script.

I have set up my Apache httpd.conf as best I know how. Have tried to read through the man apache and also have checked out all I can in Quigly's book on cgi along with doing some goodle searches. Nothing so far gets me over that first hurdle, and that being, making a perl/cgi connection.

Please help, I have been dealing with this for about 4 days now and daylight is burning.
I know that it is probably something basic that I should have found and should already know, but, I can't find it.

Thanks,

Kent
 
Forgot to ask, have you tested your scripts using the .pl extension? Maybe you could also include your code, as it may be a simple error with your code even.

Here is the code, exactly as it comes from the book. And yes I have tried it with the .pl extension.

The actual path to it is:

/var/

#! /usr/bin/perl
# The HTML tags are embedded in the here document to avoid using
# multiple print statements
print <<EOF; # here document in a CGI script
Content-type: text/html
<HTML><HEAD><TITLE>Town Crier</TITLE></HEAD>
<H1><CENTER>Hear ye, hear ye, Sir Richard cometh!!</CENTER></H1>
</HTML>
EOF

Thanks,

Kent
 
Have you changed the permission of the file to be executable?

chmod 755 example16.cgi

If you can do this:

perl example16.cgi

and not get any errors, then something is wrong with httpd.conf. Couldn't help you much with that, though.

Ryan
 
Think I found the problem. Someone on the Apache board pointed out to try it with a blank line after the 'Content-type' statement so it looks like so:

#! /usr/bin/perl
# The HTML tags are embedded in the here document to avoid using
# multiple print statements
print <<EOF; # here document in a CGI script
Content-type: text/html

<HTML><HEAD><TITLE>Town Crier</TITLE></HEAD>
<H1><CENTER>Hear ye, hear ye, Sir Richard cometh!!</CENTER></H1>
</HTML>
EOF

Adding the blank like made it work.

Regards,

Kent


 
Now it's not working. Tried it over again and now it does not work. rats.

Kent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top