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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing perl

Status
Not open for further replies.

RhythmAce

Technical User
May 22, 2001
2,869
FR
Hi guys,
This isn't a programming question but I hope someone here can help me out. I can't get cgi to work on my server. I'm running Apache 1.3.19 on RedHat Linux 7.1. I downloaded the iso image files and installed from them. I have read the manual over and over and used every configuration possible to get the server to execute cgi but it just ain't happening. I get 2 errors in my log every time I try to run the script from my browser. The 1st one says (2) No such file or directory. The 2nd says Premature end of headers. If I misspell the name of the file I just get one message that says File not found so i'm thinking that the 1st message is coming from the script and also causing the second. I've tried to call the script from the command line but I just get a display of the source code without any execution at all. My question is, should I be able to execute cgi scripts from the command line by typing "perl myscript.cgi"? If I use my browser and type in the URL I get the errors. If I type in the the path, I get the source code. Assuming my server is setup correctly, is there a way of testing perl to see if it is doing everything its supposed to. I'd be thankful for any little bit of help I can get on this.
 
When in your browser you get the cgi script source displayed instead of the script actually executing, that's usually a problem in the Apache httpd.conf - check these settings:

make sure you have an AddHandler for cgi-script, like this:
------------------------------------------

#
# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into the server
# or added with the Action command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
AddHandler cgi-script .cgi

Also check your "ScriptAlias" settings:
---------------------------
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/path/to/your/cgi-bin/"


When you run a cgi script from the command line, if your script doesn't have any syntax errors is will just give you this message

(offline mode: enter name=value pairs on standard input)

My guess(just a guess) is that Perl on your machine is OK, and it's your Apache config that needs attention. Check the settings I pointed out above, and if you make changes to httpd.conf, *DON'T* forget to restart your webserver.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Thanx hmerril,
My question was so long, I probably didn't make things too clear. I only get the source code when I type the path of the script in my browser or when I call the script from the command line, such as "perl path/to/my/script.cgi. When I type the URL of the script in my browser (or click on the link), I get the errors I mentioned. Here is how I currently have it set up:

ScriptAlias /cgi-bin/ "/var/
<Directory &quot;/var/ AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

I also tried using AddHandler cgi-script .cgi .pl but I get the same results. The reason I prefer to use &quot;ExecCGI&quot; within a directory container is because AddHandler tells the server to execute the scripts where ever it finds them. (that's my understanding anyway) :eek:)

I've always had my website hosted by someone else before so I don't know how perl/cgi is supposed to act locally. Shouldn't I be able to type &quot;perl myscript.cgi at the command line and have it execute? The scripts I'm using have been on other servers and worked just fine so I know it has to be something on my end. What I need is to know if the problem is with perl or my server and i don't know enough about either to exclude one or the other. If you need more information such as my error log, I can post a section of it here. I'm posting in the apache forum too but not getting many answers. Thanx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top