CGI Script Basics

 

Understanding CGI Scripts

CGI scripts are used to process information on your Web site. Think of scripts as mini-programs that execute on the server to accomplish tasks. Each mailform, counter, guestbook, or other interactive feature you place on your site must not only have an HTML page, but also a script that works behind the scenes to process the information.

  • Our servers support Perl scripts easily. Other scripting languages, such as C, require the script to be compiled on a system running the same version of Unix as the server before they will function. So, if you do not have access to a Linux UNIX server, you will most likely be limited to Perl scripts for your account.

  • For your convenience, we provide script-making utilities on your account Control Panel (at http://www.yourdomain.com/cpanel). These tools allow you to setup common ready-made scripts right from the Control Panel, which will be placed on your Web site, ready to use! The Control Panel has tools for creating hit counters, mail forms, guest books, password protected subdirectories, searches, free-for-all pages, random link pages, and so forth. Using these tools, you may not have to upload your own scripts at all.

When uploading Perl scripts to your account make sure that they are uploaded to your cgi-bin directory and that you upload them in 'Ascii' mode; not 'Binary' mode. The cgi-bin directory is located off of your root directory. Also, you should make sure that you have the proper permissions set on your Perl scripts.

  • Path to perl: /usr/bin/perl

  • Version of perl: 5.005

  • Path to sendmail: /usr/sbin/sendmail

  • Operating system: Linux


    Troubleshooting:

    • "Internal Server Error"- This does not necessarily mean that the server is mis-configured; in fact, it usually means that a CGI script a user has installed is not functioning correctly, and the server is detecting this. Common causes are: the file is not executable, there is a malformed header, or it is has an incorrect path reference when using a Server Side Include. Also make sure there are no control characters included in the script by using 'Ascii' mode when uploading, or by using the 'Remove Control M's' utility on the Control Panel.

    • Many errors in Perl CGI scripts can be more easily diagnosed by adding

    use CGI::Carp qw(fatalsToBrowser);

    to the top of the program. This will cause fatal error messages your script generates to be sent to your Web browser.

    • Make sure you have your path to Perl listed correctly in the script, and the HTML code of the page correctly refers to the script.

    Now we have gone through the basics of CGI programming. With this knowledge you can now create mail programs, guest books and more or simply log into your AlphaOne control panel and access our scripts area to have these scripts added to your account. Lets move on to step four and begin to get a better understanding of advanced account administration features.

  •