Domain Registration from
$12.50/year
Domain Registration from
$12.50/year

The Best Web Hosting Deal Special

Only $17.95 / mo

Using

Using and Troubleshooting CGI Scripts

All Unix web hosting accounts that support a domain name will allow you to install and use your own CGI scripts.

Keep in mind that using CGI scripts and CGI programming are a lot more involved than HTML, and require a basic understanding of file permissions, directory structure, Unix commands and programming in languages like Perl or C. If you are new to web development, or do not have these skills, we suggest using some of the pre-installed CGI scripts that are available.

CGI Script Usage

  • Here are some guidelines and tips for using CGI scripts with your Unix web hosting account.
  • The name give to your CGI scripts must have the extension .cgi (for example, search.cgi, mail.cgi, etc). The extension .cgi tells the server that the file should be processed as a CGI script. If the file extension used for your script is .pl, you will need to rename your script before it will work.
  • CGI scripts can be placed in any sub-directory within your public_html directory. They do not need to be placed in a directory named cgi-bin. If the directions for your CGI script say to place the script in your cgi-bin directory, you can place the script in any sub-directory within your public_html.
  • Do not create a directory in your public_html named cgi-bin. The cgi-bin directory is a special system directory that contains pre-installed CGI scripts, and cannot be used as a sub-directory to store your own CGI scripts. If you want to make a directory for your CGI scripts, we suggest using the name cgibin.
  • Make sure that you set the proper permissions for your scripts. Users must be able to read and execute your script. This can be done by telnet using the command "chmod 755 script.cgi", or by FTP (if your FTP software supports this).
  • If your script is written in Perl, the first line must be configured to tell the script where Perl is located. The first line of your script should read:
    #!/usr/bin/perl
  • The location of the sendmail program on the server is:
    /usr/lib/sendmail
  • Usually, CGI scripts need to have some configuration done that includes the path to your directory. To configure your CGI script, you will need to determine your home directory.
  • If you need to edit a CGI script, you must use a simple text editor (like Notepad or SimpleText). You cannot use a program like Microsoft Word or WordPerfect.
  • Never upload CGI scripts in BINARY transfer mode - always upload CGI scripts in ASCII transfer mode. Even if your FTP software has an "automatic" setting, it's best to force it to upload in ASCII for CGI scripts. When a CGI script is uploaded using the wrong transfer mode, you will get a "500 Server Error".
  • If your script needs to write to certain directories or files, make sure that the permissions are set to allow this. Normally, a CGI script would include directions telling you what the permissions should be set to. A Unix / CGI Script Permissions Guide is available if you need more information.
  • If you need to run CGI scripts as your own username, you can use a CGI wrapper to run your scripts. The wrapper installed for you is called cgiwrap.

CGI Troubleshooting

When installing a CGI script, there are usually problems. Each CGI script is different and requires different settings, and even the pros have problems.

By far, the most common error you will get when trying to set up a CGI script is a "500 Server Error". This error means that there is something wrong with the internal workings of your script. Here are the most common problems/solutions:

  • Upload your script again. If the script was uploaded to the server using BINARY mode instead of ASCII mode there will be extra characters in the script, and a 500 server error will result.
  • Check the permissions on your script. CGI script permissions need to be set to 755 (more information on Unix / CGI Script Permissions is available).
  • If your script needs to read or write to other files on the server, check to ensure that the correct permissions are set on those files.
  • Try running your script in from telnet. If there is an actual error in the script, this will tell you what line the error is on and what the error is. To do this, log in using telnet, go to the directory containing your script, and enter:
    ./scriptname.cgi
  • If you want to see the web server error logs on the, log in using telnet, run your script and then enter:
    tail -50 /usr/local/apache/logs/error_log
    This will give you the last 50 lines of the error_log, which may contain errors from your script.
  • Check to make sure that there are no blank lines at the TOP of your script.

HELPDESK

WEB HOSTING SOFTWARE VERSIONS

  • 5.2.x 5.3.x 5.4.x 5.5.x 5.6.x 7.0.x 7.1.x 7.2.x

  • 5.0.xx 5.1.x 5.5.x 5.7.x 10.x.x

  • 11.6x.x 11.70.x 11.72.x

  • 4.7.x (older versions available)

  • 5.2.x 5.3.x 5.4.x 5.5.x 5.6.x 7.0.x 7.1.x 7.2.x

  • 5.0.xx 5.1.x 5.5.x 5.7.x 10.x.x

  • 11.6x.x 11.70.x 11.72.x

  • 4.7.x (older versions available)

top

SecurityMetrics Credit Card Safe

Developed by