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

CGI still will not work

Status
Not open for further replies.

RhythmAce

Technical User
May 22, 2001
2,869
FR
What is everybody doing that I am not? After Rninja suggested that maybe my files were corrupted from bouncing them back and forth between windows and linux partitions, I thought it was possible that my ISO image files were corrupt too so I went to the store and bought the standard version on CD-ROM. I'll list everything I did so maybe someone can see what I'm doing wrong.

First I selected "install" rather than upgrade (I wanted a clean install)then I selected to install "ALL" packages. After the install was complete and my system and network settings were configured, I rebooted.

After logging in as root, I made a copy of the original httpd.conf file then edited the Listen, ServerAdmin and ServerName directives and left everthing else as it was. I started httpd then typed my web address into my browser and got the "Test Page".

I downloaded a new version of formmail.cgi and loaded it into the existing cgi-bin directory and tested my script and got the same errors as before (see the 500 Server Error thread). I tested other scripts and get the same errors. The only difference now is that it will execute my "hello, world" script from both the browser and command line. So I made some headway. :eek:)


 
i know how you feel. i have the same problem but instead of error 500 i get a 404 error.
 
Yeah but yours is easy to fix and mine ain't. :) If you're getting error 404 that means the url isn't right. If you are sure that you have it typed correctly, look in your error log and see if it is appending the path to your DocumentRoot. For example, If your url is " and your error log say "File does not exist: /var/ the problem is your cgi-bin is not Aliased. If you are going to only have cgi scripts in your cgi-bin then you can use ScriptAlias and the ExecCGI directive in a directory container. Some scripts call html files and they wont work with this setup so you can use Alias instead if ScriptAlias and also uncomment AddHandler to tell it which types of files are cgi scripts. A couple things to look for are to make sure there are no comments in the line directly following a directive. Insert a blank line if there is. The other thing is to make sure your are using the trailing "/". "Now go do the right thing" :)
 
sounds like rninja was right. If your helloworld script is working, you may want to try setting the filetype to unix in vi. Like this.
open vi:
vi formmail.cgi
:set filetype=unix
hit return
:wq

This works for me when i have customers upload perl scripts from a windows client.
 
have you made sure the path to perl is correct so that it executes properly?
your "hello world" script may run because it has the right path. A long time ago when I used to think it'd all work like plug-n-play, I spent a few months trying to figure out why none of the scripts worked on my machine. I learned perl and cgi only to find out that my problem was in the first line of code. Make sure it includes the filename and not just the path. Say the perl executable is in /usr/local/bin. Your first line of code should be:

#!/usr/local/bin/perl

On windows, if it's in c:\perl\bin, it would be:

#!c:/perl/bin/perl

I'd recommend you look at the error logs and find out why the script isn't running. It could very well be the unix vs. windows file like Push said, or it could be your path, or your script. Whatever it is, the error logs usually tell you what's wrong.
Steve Kiehl
webmaster@nanovox.com
 
No, i think the path to perl on windows is
#!c:/perl/bin/perl.exe
 
your path in windows should be
#!/perl/bin/perl
if perl is located at
c:\perl\bin\perl.exe
 
No, windows is NOT like linux. You must have the .EXE at the end. MUST.
 
MUST NOT.....not on my machine anyhow :)
i have perl installed on w2k and with that path it works fine.

and, yeah, i agree. Windows is NOT like linux, at least linux works.
 
In windows, if perl is located at C:\perl\bin\perl.exe you can use any of the many ways to point to it:
#!/perl/bin/perl
#!/perl/bin/perl.exe
#!C:/perl/bin/perl
#!C:/perl/bin/perl.exe
Believe me, I've tried and the all work the same. The way it's set up, "/" = "C:/" and if you ever tried running a program from the dos prompt, "perl" and "perl.exe" will both call perl.exe.
Steve Kiehl
webmaster@nanovox.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top