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

CGI - C language

Status
Not open for further replies.

butthead

Programmer
Feb 24, 2002
545
US
I am quite new to apache and the whole web server business.

The question I have is about cgi applications. I am running
apache 2.0 on a win98 machine. I have 2 domains going as
of now. and I have cgi enabled. the call to the perl app
printenv.pl works fine. I just declare this to inform that
I can figure out most things if I have the proper
information at hand. I have been searching for information
about implemeting the c programming language in the cgi
mechanism. since I know c pretty well I was hoping to
start there.

my question is this. do I use a compiled executable such
as "dothis.exe" or do I use some form of CScript text file
in conjunction with an interpreter. and how do I do this
in apache. I am obviously missing something and hope I am
not on a wrong track. I will learn perl or whatever but I
was hoping for some instant gratification.
 
The simple answer is yes you can use compiled C code (i.e. dothis.exe). As long as it is a console app you should have no problems.
 
You don't have to configure apache to do this. The interpreter is determined by the scripts header and file extention. If you want to learn to write cgi scripts, get a book on cgi for the language you prefer. You may also want to look at some code from scripts that other people have written. A good source for that is
 
I have made a plain executable as follows

#include <stdio.h>
void main ()
{
printf(&quot;Content-type: text/html\n\n&quot;);

printf(&quot;<HTML><HEAD><TITLE>Hello!</TITLE></HEAD>\n&quot;);
printf(&quot;<BODY><H1>Hello, World!</H></BODY></HTML>\n&quot;);
}

compiled it and put it in the cgi bin dir3ectory.

I then called this from explorer.

192.168.0.4/cgi-bin/dothis.exe

I get only the internal error and thats it. I was under the understanding that the only requirement for the code was that the output had to be to the stdout stream. I just need a concrete example and then I am off and running. I promise not to bother any body until I have gone through the documents from ...

this looks like a very good place to start. thanks for the heads up. At least I know I am not completely lost.

tomcruz.net
 
Take a look at your error logs to see if they can give you a little more insight to why it can't run the script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top