Friday, March 6, 2009

CGI scripting

Plain old HTML is very static and unchanging. CGI is an attempt to allow a static web page to interface with a web server. Basically, a web page is static and the CGI interface is dynamic. For example, if you wanted to look up a customer number, you could write a small routine in CGI to do so. This routine would transmit the customer number back to the server, which would query the database and send it back to the web page for display.

This is a simple example of CGI, which is actually extremely powerful. There is virtually no limit to what you can implement with this technology. It is important to remember that CGI is the technology of allowing a web page to run scripts or programs on the server. The actual language in which a CGI routine is written can vary. Perl is very popular, as is C and C++. Other languages such as TCL may also be used.

It's important to understand that CGI is not a language in itself. It is instead a specification for allowing the web page to communicate with a web server. You can write CGI applications in just about any language, including Fortran, C++, TCL, Visual Basic, Applescript or Perl. some of these languages are compiled and some can be run as script.

For security reasons, CGI code must run out of a special directory on the server, generally called cgi-bin. The webmaster will install CGI programs for you in this directory. There is much more to CGI than I can teach you here, and there are many very good references and sites for you to read and explore.  The point is that CGI is an option, especially if you have some control over the server.

No comments:

Post a Comment