CGI Programming OpenFAQ

What is a CGI Script?


CGI, or "Common Gateway Interface", is a specification which allows World Wide Web users to run programs on your computer. CGI isn't a programming language in itself; rather, it is a gateway which allows programs or scripts written in other languages to be run over the Internet.

CGI programs usually take input passed to it from a form on a web page, process the information somehow, and then format the results in HTML. The result is a web page that is generated on-the-fly.

The language of choice for CGI processing is Perl, or "Practical Extraction and Reporting Language". Perl is used often because it is specifically designed to butcher multiple text files and format them nicely, making it exceptional for writing HTML.

Other languages used occasionally for CGI Scripts are (in descending order of popularity) C/C++, Visual Basic, AppleScript, UNIX Shell, and Tcl.

CGI Scripts can do almost anything when they are cleverly written. Scripts exist which run search engines, manage chat rooms, and even control robotic arms remotely. As a matter of fact, this FAQ is also maintained through extensive use of Perl CGI scripts (Good job, by the way, Tom!).

Several resources already exist to get you into CGI programming. One of my favorite places to start when I need inspiration is The CGI Resource Index, which has hundreds of scripts already written. You can look at the source code to see how the scripts are written.

If you want to write your own CGI programs in Perl, get a copy of either (my personal preference) or These libraries automate the process of getting form input from a web page through CGI. They also provided a limited set of routines to begin building the framework of a resulting web page.

For information on writing CGI scripts with Python, consult the Web topic guide at for a comprehensive list of tools and documentation.

Of course, if you are in need of programming help, the CGI Programming OpenFAQ is always available! ;)

Previous | Next | Table of Contents