Affordable Web Hosting with Excellent Customer Support internet connection free month hosting

Using the Common Gateway Interface (CGI)

The NCSA defines the Common Gateway Interface (CGI) as: "...a standard for interfacing external applications with information servers, such as HTTP or Web servers."
Basically, the CGI allows you to call server-side scripts from HTML documents in order to provide dynamic content.

Some examples of scripts that use the CGI include:

  • Site Searches - allow visitors to your site to search for words or strings of text. We offer a pre-packaged script for this in the netConsole.
  • Form to Email - if you need to gather visitor feedback or any other information from your site, a form to email script is the way to go. We offer a pre-packaged script for this in the netConsole.
  • Browser Detection/Redirection - enables you to detect which web browser your visitor is using and direct them to an appropriate page. View an example of Browser Detection/Redirection.
  • Shopping Carts - allow visitors to use a virtual shopping cart while they browse your online store. We offer a pre-packaged script for this in the netConsole.

CGI scripts can be written in a number of languages, including, but not limited to: C, C++, and Perl.

By default, scripts should be placed in your cgi-bin directory but they can exist and function anywhere in your webshare (public_html) or sub-directories.

Locations of System Binaries

Scripts utilizing the CGI will often need to make use of certain system binaries. The two most commonly needed of these are Perl which is located at /usr/bin/perl and Sendmail which resides at /usr/lib/sendmail. If you need to know the location of any other items on your server you can easily find them using whereis. For example, typing whereis -b perl (the "-b" switch tells whereis to ignore all but binary files)at the shell prompt would get you the following results:

perl: /bin/perl /usr/bin/perl5.00503 /usr/bin/perl5.005 /usr/bin/perl /usr/bin/perl5.005_03 /usr/local/bin/perl

CGI Troubleshooting

The CGI Troubleshooter

If you write your own CGI scripts or make use of third-party scripts, this tool will come in extremely handy. The CGI Troubleshooter is designed to detect, and in most instances, correct errors in a CGI script's programming, installation, and configuration settings.

Troublesome CGI scripts often suffer from one of these common errors:

  • The script was not uploaded in ASCII format. Most FTP clients allow you to choose which transfer method you'd like to use, CGI scripts written in Perl should always be uploaded in ASCII (text) format.
  • The script has not been given the correct permissions. Most scripts will need certain permissions in order to function correctly. Some FTP clients allow you to modify a file's attributes directly. If yours does not, you must ssh to your account and use the chmod command to alter your file's permissions. Typing chmod filename 0755 will fix most permissions-related CGI issues.

Related Items