Click to See Complete Forum and Search --> : HTML question regarding CGI


mindcooler
03-05-2004, 04:28 PM
Hello, I am trying to get my webserver to execute a cgi script (well, not really a script, it's written in C). However, I am getting the following error:

HTTP Status 404 - /cgi-bin/simple

--------------------------------------------------------------------------------

type Status report

message /cgi-bin/simple

description The requested resource (/cgi-bin/simple) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.19


My .html-file looks like this:

<HTML>
<HEAD>
<TITLE> Test simple CGI Program</TITLE>
</HEAD>
<BODY>
<H2 ALIGN=CENTER> Test simple CGI program</H2>
<p>Click below to test the simple CGI program</P>
<ul>
<a href="/cgi-bin/simple"> Simple Program</a>
</ul>
</BODY>
</HTML>


If I change /cgi-bin/simple to /cgi-bin/simple.exe I get a File Download dialog box instead. What am I doing wrong? I know next to nothing about HTML, I am usually into application developement using c or c++.

Grateful for any replies

ph34r
03-05-2004, 04:43 PM
You need to point to simple.exe, but if you are getting a download prompt, then Apache is not set to recognize that directory as a cgi-bin place.

mindcooler
03-05-2004, 04:50 PM
Thanks for the quick reply. I had a feeling I had to specify the full name of the "script" to be executed for it to work, but I didn't know how I should tell my web server it should be executed not downloaded. I didn't know if I was missing something in the html-code itself or if it was a setting for the server. First time using Apache Tomcat, will see if I can find how to make it recognise the directory as the cgi-bin directory.

bwkaz
03-05-2004, 07:58 PM
The solution on a Linux box running Apache is the ScriptAlias directive in httpd.conf (or one of the arguments to the Options directive). But if your compiled program has the .exe extension, then you're probably running Windows, so your Apache config files might be different.

mindcooler
03-06-2004, 03:21 AM
Thanks for your reply bwkaz. Yes, I am on Windows atm. My Slackware installation is not healthy right now and I don't plan on reinstalling it until I get some new hardware next week. Anyway, I ditched Apache Tomcat and installed ordinary Apache instead, putting my script in the cgi-bin directory it creates during installation, and now everything works great! When I get a working Linux installation again, I will confirm the necessary steps to complete to get the same behaviour there. Thanks for your replies!