For example, let's say that you wanted to "hook up" your Unix database to the World Wide Web, to allow people from all over the world to query it. Basically, you need to create a CGI program that the Web daemon will execute to transmit information to the database engine, and receive the results back again and display them to the client. This is an example of a gateway, and this is where CGI, currently version 1.1, got its origins.
The database example is a simple idea, but most of the time rather difficult to implement. There really is no limit as to what you can hook up to the Web. The only thing you need to remember is that whatever your CGI program does, it should not take too long to process. Otherwise, the user will just be staring at their browser waiting for something to happen.
If you have a version of the NCSA HTTPd server distribution, you will see a
directory called /cgi-bin
.
This is the special directory mentioned above where all of your CGI
programs currently reside. A CGI program can be written in any language
that allows it to be executed on the system, such as:
/cgi-src
directory that came with the server distribution, you will find the source code for some of the CGI programs in the /cgi-bin
directory. If, however, you use one of the scripting languages instead, such as PERL, TCL, or a Unix shell, the script itself only needs to reside in the /cgi-bin
directory, since there is no associated source code. Many people prefer
to write CGI scripts instead of programs, since they are easier to
debug, modify, and maintain than a typical compiled program.