CGI/Perl scripts information


CGI scripts are programs that accomplish a specific task. If you have one or want to write one, here are the things you should know of.


Specs & limitations:
Installation Instructions:
  1. Changing Parameters: Carefully read the installation instructions that come with your cgi script. Make any necessary changes to adapt the script to your server. This is where you might need to know about the server and program paths. Remember that UNIX is case sensitive, so be sure to spell right.

  2. Removing Carriage Returns: When edited in a WINDOWS or MACINTOSH environment, your scripts will end up containing hidden carriage returns that have to be stripped before your scripts can run. To do this, please read our "saving with UNIX line feeds" instructions to learn how to do this.

  3. Uploading: Upload your script via FTP to a directory on your site. Remember that scripts can not run in your root directory (the first directory you see when you use FTP). Instead, put the script(s) in an existing directory or create a new directory and put them in there.

  4. Setting Permissions: You need to set the right UNIX permissions to make your script executable. Go to your File Manager. Locate your script using the File Manager (use the left frame to browse through your directories until you see your file in the right frame). Each file has a set of checkboxes associated with it, grouped under two headings, "Owner" and "Other". The checkboxes are used to set permissions for that file. For scripts, you need to change permissions to chmod 755, which translates to the following:
    After you have checked those checkboxes, click on "Change Mode".
If you have followed these instructions, your script should run perfectly. If this is not the case, please follow our steps for debugging scripts.


Server and Program Paths:

Your scripts will most certainly require you to know one of the following paths, if not all. Here they are:


"Saving files with UNIX line feeds" instructions:

Your scripts have to be saved with UNIX line feeds so that carriage returns are stripped.


Debugging Scripts:
  1. Use the Perl syntax checker to check if your script contains any perl syntax errors. The perl checker will not reveal any paths errors, but only language errors. If there are any, you need to fix them or re-write the script properly.

  2. If the script looks fine with the perl syntax checker, check again to make sure your paths are set correctly.

  3. Also, check to see if the script is performing a "write" action. This means that your script is writing data to a file or a set of files. In these cases, in addition to setting permissions on the script according to the previous instructions, you also need to also change the permissions on files that are being written to. Again, use the File Manager to locate the file(s), but this time, check ALL checkboxes for each file and click on "Change Mode". For example, guestbook scripts (guestbook.cgi) usually write guestbook entries to a file called guestbook.html. Other cgi scripts sometimes write data to a log file. Therefore, you would check ALL checkboxes for "guestbook.html" because it is being written to by "guestbook.cgi".

  4. If your script still doesn't work, please email the support team. When emailing support, please specify your domain name, username and the URL for all the necessary and relevant files.