View Full Version : C & CGI problems

03-06-2005, 06:12 PM

I am very very new to cgi scripting, and am in need of some assistance.

I was recently given a cgi script, in the form of a C file. Being new to cgi, I checked some websites and was told to do the following:

gcc -o test.cgi test.c

This produced the executable to be run. If I run it from the command line, it works fine - though if I try to call http://myhost.com/cgi-bin/test.cgi I get a 500 Internal Server Error.

I know that a perl cgi script works, as there was an example in the folder already.

Is there a setting somewhere I should be fixing? Or shoul I be doing something differently to get a C program to cgi?

Thanks in advance!

03-06-2005, 08:04 PM
Are you using your own server, or a webhost?

I don't imagine many webhosts have their cgi-bin directories
set up for C (usually set up for Perl).

03-06-2005, 08:20 PM

I am hosting it locally, so I can make any configure changes if necessary - all I would need to know is what to change, or somewhere that might help me in deciding what to change.


03-06-2005, 09:42 PM
I don't have my own local server, but I found this ...
It looks like they do it different than you did:


You didn't mention what the script was that you
compiled and tried to run. But before anything is
sent to the browser for display, you need to specify
the type:

printf("Content-type: text/html\n\n");

This is true for both C and Perl.

try some of the examples they show.

03-06-2005, 10:07 PM

Thanks for the reply,

The examples on that website seem to work good. I guess this means there is a problem with this particular code, I will have to somehow figure out what to fix.

Thanks for your help.