When you are dealing with Web pages, you will often hear people talk about CGI or CGI scripts without ever explaining exactly what that is. Essentially, CGI is the connection (or interface) between a form on a Web page and the Web server.
Some Things to Remember About CGI
- CGI is not the program itself
CGI is simply the interface between the Web page or browser and the Web server that runs the program.
- You must have CGI access to run programs on your Web page
Many of the less expensive and free hosting providers do not allow CGI access on their servers. Contact your hosting provider for more information.
- Any program or script that will run on your Web server, can be used as a CGI program
Most people use Perl to write their CGI scripts, but other languages include C and C++, Tcl, and UNIX shell scripts.
Uses of CGI Scripts
Some of the most interesting uses of CGI are to create Web documents that depend on user interaction. There are scripts to take readers to random pages on the site, create pages specific to them based on form input, and generate pages based on databases of information.
CGI scripts are used to resolve form data, put that data in to databases, send the data out as an email message, respond to the form entry with email or another Web page, and much more.
CGI scripts also are used for behind the scenes interaction with Web readers. They can set and read cookies, get and tabulate information such as browser and operating system, calculate hit counts, and monitor Web traffic.
Why Use CGI?
Why Not Use CGI?
The biggest drawback to CGI Scripts is that they can put a lot of load on a Web server. Poorly written programs can fall into endless loops tying up server processor time. The Web browser will time out (usually after around 5 minutes), but often the server will continue to run the program until a system administrator comes in and shuts off the faulty script. The browser based scripting tools mentioned above have the advantage of running off the reader's computer. They use the processor locally rather than on the Web server itself, and so are less intense on the Web server.