cgi and shell scripting, setting it up?
I have never programmed cgi scripts before, but I have done shell scripting and c++, and c programming.
My question is this. I want to creat a check box form( in html or cgi)
then hit submit and it will take me to a server hosted on a NETdimm.
so if I hit yes on the check box it will take me to the cgi script and in there the script will execute a c program that will run a function on the board.
I need to use cgi as its the only thing that will interface with my uclinux boa web server.
I am a little confused as to how to go about setting this up,
can I create the form entirely with html and then when I hit submit it will take me to the /cgi-bin/myprogram.cgi..... or can I do the entire web page in the cgi script. I am confused as to how this works.
how to test( dont have the boa web server setup yet)
some good links to cgi tutorials, and sample scripts(only in shell scripting/ perl not supported)
All cgi is, is a program (written in any language) that prints html tags to stdout and receives input through enviroment variables. I have a CGI library that I wrote (it's C++) that makes writing CGI scripts REALLY easy.
I will e-mail it to you, or post a link here (so, just incase any body else want to use it they can). But as I always say: I am not responsible in any way for any damage caused by any of my code, though you may use it as you wish (unless I specify otherwise). I will post the link as soon as posible.
A good resource is CGI Resource Index, also for more details is the CGI Documentation.
THe trick is to set up the form in HTML, Then input from the form will be recieved by the program through env vars and you output to stdout which will be recieved by the browser as an HTML document or redirection.
To set the form to execute the cgi when the user hits submit is part of the form tag. i.e
Well! I am finally done! Sorry, I didn't think it would take that long! I had to write documentation for using my library. It is included in the archive. You can download that here:
I hope you, and who ever else uses this library enjoys it.
You may use my code however you see fit. However I am not responsible in anyway for any damage caused by my code in any shape or form.
Oh! Also, if/when you are done with your CGI script(s) (who ever uses my library) I would appreciate it if you e-mailed me with the link, so I can go see it! Thanks! Enjoy!
Hey, thankyou, that helps alot. ( I havent read the documentation yet)
I have a few other questions, How can I test the cgi on my own computer...that is how do I set up a server on one computer to test the scripts and html, either in windows or linux( I work with both alot) can I use httpd in linux ? what about windows
also: I went to some other sites with cgi tutorials and they list environment variables : $query string etc...... they were like this:
now do I have to type or code all of these variables?
i'm also learning this.
what i have done is install apache (in linux that was), then you have to configure cgi as described here: http://httpd.apache.org/docs/howto/cgi.html
they also described how to test it i think. For myself i wrote some small shell commandos in a script and tested it. Oh yeah, for input from html forms to cgi i used proccgi.sh (you find it on google or other search machines).
I got it working in no time
Well I have RedHat 9.0, and it comes installed with Apache. So all I have to do is compile my cgi script, and copy it to /var/www/cgi-bin, then (after starting Apache... wich is done like this: "httpd" as super user) I open my fav' browser, and type: http://127.0.0.1/cgi-bin/myscript.cgi
Thats all there is to it!
can I save the my .cgi as a .sh? or can I write the script in unix shell or C programming and save it as .cgi?
what script is saved as .cgi?
the shell script?
|All times are GMT -5. The time now is 03:20 AM.|