CGI

What is CGI / CGI-BIN?

CGI, otherwise known as, Common Gateway Interface is a set of rules that describe how a Web Server communicates with another piece of software on the same machine, and how the other piece of software (the “CGI program”) talks to the web server. Any piece of software can be a CGI program if it handles input and output according to the CGI standard.You can often see that a CGI program is being used by seeing “cgi-bin” in a URL.

When should I use CGI?

CGI is great for adding interactivity to your site. There are some things that JavaScript and other client-sided techniques simply can't do, and this is where CGI comes in. Since client-sided techniques are implemented in the browser, it is difficult, if not impossible, to remember state information (other than using a JavaScript cookie). To accomplish this, you have to implement a CGI-based solution. CGI applications can interact with databases, catalogs, search engines, guestbooks, counters, you name it.

Are there any drawbacks of using CGI?

As with all things that must travel back and forth across a network, CGI applications can be slowed down considerably if network is slow. On top of that, if your script is long or has to do a lot of processing, your visitor will have to wait a bit until your script is finished running.

Probably the biggest concern with CGI programs is security. Whenever you let anyone on the internet run a script located on your server, you are taking a risk. Things that you can do to minimize this risk is to code defensively, like checking for malicious user input, and also taking advantage of pre-defined environmental variables to control who has access to your script.

Where can I find more information about CGI / CGI-BIN?

Here are some useful links for more information on CGI / CGI-BIN:
Perl

What is Perl?

Perl, or Practical Extraction and Reporting Language, is a robust programming language frequently used for creating CGI programs on Web servers because it is faster than UNIX shell script programs, it can read and write binary files, and it can process very large files.

Why is Perl so popular?

There are a few great reasons for this. Probably the best reason is that Perl can do wonderful things with text, which makes it ideal for web-based applications. In addition to this, Perl is relatively easy to code in, especially if you have programming experience in other languages. Be warned, though, that Perl can become very cryptic if whoever coded the script used Perl's special variables and didn't bother to comment properly. Perl has a shallow learning curve at first, but the curve can be a very long one should you choose to delve into advanced Perl development. Always remember, though, that in Perl, "there is more than one way to do it."

One thing I should point out is that Perl is NOT just for CGI programs. Perl also finds itself quite at home in the Unix environment where system administrators rejoice in Perl's ability to perform administrative tasks on a server. It has many built-in functions that duplicate regular system functions like making and removing directories, creating files, and getting system information.

Where can I find more information about Perl?

Here are some useful links for more information on Perl: