[CSM CGI Main Menu] [Application: http://www.students.mines.edu/setup/] [Examples: http://www.students.mines.edu/examples/] [Guidelines: http://www.students.mines.edu/setup/guidelines.shtml] [CSM Home: http://www.mines.edu/] [CGI Home: http://www.students.mines.edu/]
[CGI Examples]

Common Gateway Interfaces (CGI's)


CGI Introduction

CGI's (Common Gateway Interfaces) allows users to create complete HTML documents on the fly. This can be useful if the information presented in the document changes frequently, the information presented is based on the contents of another file (e.g. a database), the layout is highly repetitive and can be more easily automated, the page needs to perform an action based on the clients activity or responses (e.g. read information from a form and e-mail the results to another person). There are many reasons to use CGI's.

Unlike SSI's though, these programs must define the entire HTML document, not just a portion of it.

A useful sources of information about CGI's can be found on the Guidelines page.

NOTE: There is little point in editing the files created with a CGI. These files are created when they are requested. Editing and saving the pages using built in browser editors, such as Netscape or Internet Explorer, will only create unused files on the web server. These browser/editors download the displayed/served document. The contents of this document have been dynamically generated, and the code (C/C++ or Perl) is NOT included if the final document sent to the client.
A downside of CGI's, is that they can severely tax the server system resources. CGI's and SSI's, unlike Java Applets run on the server computer rather than the client computer. For this reason, CGI's and SSI's should perform only small, fast tasks. If they perform large tasks, or are called concurrently by many clients (a problem at popular sites), the servers performance can be severely degraded. It is also extremely important to ensure the program will die in a finite period of time. Loops that could continue forever unless a specific condition occurs should be avoided, or at a minimum be very carefully written. We have had trouble will runaway processes in the past.


CGI Format

CGI's are either defined in an <HREF> like and ordinary HTML file, or the are passed as the argument in a <FORM> tag. Normally a CGI called from a <HREF> will not pass any arguments. This means the client won't influence the appearance on content of the referenced page. If carefully constructed though, arguments can be passed, and this can be useful. If the client needs to supply information, this is usually done with a <FORM>, and one the the arguments in a <FORM> statement is the CGI program (referenced by URL address, not filesystem name) which will process the data. The data in the <FORM> will be passed to the CGI as command line arguments.


Comments to webmaster@mines.edu
<i>March 1998</i>