CGI (Common Gateway Interface) is a standard way of running programs from a Web server. Often, CGI programs are used to generate pages dynamically or to perform some other action when someone fills out an HTML form and clicks the submit button. AOLserver provides full support for CGI v1.1.
Basically, CGI works like this:
The program run by CGI can be any type of executable file on the server platform. For example, you can use C, C++, Perl, Unix shell scripts, Fortran, or any other compiled or interpreted language. You can also use Tcl scripts with CGI, though the extensions to Tcl described in Chapter 5 of the AOLserver Tcl Developer's Guide are not available through CGI.
With AOLserver, you have the option of using the embedded Tcl and C interfaces instead of CGI. Typically, the Tcl and C interfaces provide better performance than CGI. (See the AOLserver Tcl Developer's Guide for information on the Tcl interface and the AOLserver C Developer's Guide for information on the C interface.)
You may want to use CGI for existing, shareware, or freeware programs that use the standard CGI input, output, and environment variables. Since CGI is a standard interface used by many Web servers, there are lots of example programs and function libraries available on the World Wide Web and by ftp. This chapter describes the interface and points you to locations where you can download examples.
Here is a diagram of how a CGI program runs:
For example, suppose you have a form that lets people comment on your Web pages. You want the comments emailed to you and you want to automatically generate a page and send it back to your reader.
<FORM METHOD="POST" ACTION="/cgi-bin/myprog">
METHODcontrols how the information typed into the form is passed to your program. It can be "
GET" or "
POST" (see page 106). The
ACTIONdetermines which program should be run (see page 107).
<ISINDEX>tag (see page 106).