Computing.Net > Forums > Programming > CGI Text file on hd using c/c++/per

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

CGI Text file on hd using c/c++/per

Reply to Message Icon

Original Message
Name: dermot
Date: August 11, 2004 at 02:22:06 Pacific
Subject: CGI Text file on hd using c/c++/per
OS: windows xp
CPU/Ram: athlon 128
Comment:

Hello Everyone,

Im looking for a bit of help. I am new to the game of setting up webservers. However I have managed to install an Apache webserver on Windows XP.

I have a number of question which I hope someone out there may know:

(1) What is the best way to go about setting up a CGI-bin on an Apache webserver on XP.

(2) What I want to do is to ask a user to click Button1 or Button2 on my HTML website homepage. If the user presses button1 I want to call a program in my CGI-bin to write the letter A to a text file on my server PC desktop. If the user presses the other button (button2) I want to call a program in my CGI-bin to write "B" to the same text file(overwrite it if possible). Whatever the user presses must be sent/saved to a text file on the hard drive of the server PC. What is the best way of doing this?

(3) I really want to use a C program(as opposed to PERL) in Cgi-bin to send "A "to a text file whenever button1 is pressed and "B" to the same text file whenever button2 is pressed.

(a) Is it possible to run a C program from the Cgi-bin and execute it from the internet(I am using my own server).

(b) Does the server or Cgi-bin have to be configured in a special way to execute C programs?

(c) If it is possible then how should I best compile the C/C++ to suit this application? How do I transfer my C files from my folder on desktop to the Cgi-bin when I am ready to do so?

(d) Do I need to install special privilages to create a text file on the server HD from the internet? How is this done?

Any hepl or advice appreciated. Not many people seem to know much about CGI applications using C. Like I said before all I want to do is ask the user to click one of two buttons on my website and then write A to a text file on my server PC desktop if he/she presses tthe 1st button or write B to a text file on my server PC desktop if she/he presses the 2nd button. There is only one single text file but I could use 2 different CGI programs for each button. Thanks for taking time to read this and I hope someone can help!!



Report Offensive Message For Removal


Response Number 1
Name: Don Arnett
Date: August 11, 2004 at 16:17:01 Pacific
Reply: (edit)

Don't have time to answer every question in detail, but since there are no other answers so far:

I don't believe that setting up a cgi-bin is anything unusual for apache. I would feel safe in guessing that the default setup would include this.

A CGI program is basically any program that takes specifically format data on it's standard input stream and outputs HTML on it's standard output stream. Other than that, there isn't much special to a CGI program.

So if you can write a C program to do the things that you mention above, then you can figure out how to make that C program a CGI program. Permissions come into play a little bit because you might have to set permissions of the CGI program a certain way for it to work, but that can be worked around.

I don't remember the details and rarely cared, but a browser sends data to a CGI programs standard input. When the webserver receives a request for a given CGI program, it starts the program and passes the data to the programs standard input stream. Your CGI program will need code to read that standard input and parse the data. The easiest way to do this is to search for some C code to handle this. Otherwise, you'll have to learn a lot to write this code.

When I did this (5 years ago) I found some code named "luigi" I believe. Just search on google for "CGI C code".

Good luck


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software