MIT

Web Guide is no longer being maintained and the information on this page may be out of date. For assistance with managing course materials, please visit MIT's Stellar course management system.

Academic Web Page Creation Guide


Building Your Pages > Making Your Pages Interactive > CGI Programs

CGI Programs

CGI (for Common Gateway Interface) programs, or scripts, provide one approach to dynamic content. A common use of CGI programs is to process form submissions. These programs run on the Web server itself (not on the client computer), in response to the user accessing a URL (which may be a form submission, either POST or GET). The output from the script is sent back to the user's browser. The format of the output may be anything: HTML, a GIF image, a sound file, a data file, etc. The program may also create or modify files or databases, or perform some other action (e.g. controlling a robotic telescope).

Because CGI programs run on the Web server, the possibilities are unlimited; this is also a problem. The possibility for accidental or deliberate misuse of a CGI program must be considered in its design. It is easy for a CGI program to use up all of the CPU power, memory, or disk space on a computer. It is also easy to introduce security problems, since a user's submission may overflow the buffer on the server and write into the server's memory.

Another concern is malicious content. If the CGI script executes another program, malicious data provided by the user may cause a different program to be run.

With these concerns in mind, only a general-purpose CGI program, called cgiemail, is available through MIT Information Systems. It is designed to process form submissions into email.

If you wish to include more elaborate CGI programs in your Web site, you must run your own Web server. Traditional CGI programs are started each time they are called. For faster performance, a mechanism called FastCGI lets you leave the program running continuously, putting it in communication with the Web server when needed.