Customer Support Centre : Manual : CGI And Perl
Welcome to the CGI And Perl section of the Efficient Hosting Support Manual where you will find information about all aspects of setting up and using CGI And Perl scripts.  
The links in this section are as follows;
Introduction To CGI : Uploading CGI Scripts : Setting File Permissions : Useful Paths
Troubleshooting CGI Scripts : Pre-installed CGI Scripts : Further Reading and Related Links
  Introduction To CGI
CGI is short for "Common Gateway Interface", a protocol which allows programs which are run on a web server to communicate with visitors' browsers. CGI programs allow you to make your site more dynamic and interactive by including such features as counters, guest books and discussion boards.

Most CGI programs are written in a language called Perl, but CGI programs can in theory be written in any programming language. The Efficient Hosting servers support CGI scripts written in Perl, Python, C, PHP and the common Linux shells.

For more information about CGI and Perl, or to view archives of third party CGI scripts, you may follow the links to suggested CGI resources below.

The version of Perl currently installed on our servers is Version 5.006.
  Uploading CGI Scripts
Your personal "cgi-bin" folder is public_html/cgi-bin. We recommend that you place all your CGI scripts in this folder as it offers additional security, but they may be installed in any other folder if you find this more convenient.

Most CGI scripts (eg Perl scripts) are in the form of a text file and should be uploaded as "ASCII Text" file type, not as Binary or Raw file type. But it is also possible to have compiled CGI scripts which should instead be uploaded as Binary. If in doubt, please consult the script author's own documentation.

Return To Top of Page
  Setting File Permissions
After uploading, the file permissions for any CGI scripts should be set to 755, in order to make them executable.

For many CGI scripts it is also important that the permissions are set correctly for any files or folders which they need to access. For example, if a CGI script needs to write to a log file, then this log file will need to have write access enabled and the folder where it is located will need to give "execute" permission. If a CGI script needs to create, delete or rename files, then it will need "write" permission for the folder in which this is to be done.

For third party scripts, the documentation provided by the author usually gives specific details of the permissions required. For instance, the instructions may direct you to "chmod 755" a file.

The three digits after a chmod command (eg "chmod 755") refer to the values to be assigned to the owner, to the group, and to all others respectively.

Each number represents the sum of the values assigned for Read, Write, and Execute permission:

  Read - 4
  Write - 2
  Execute - 1

Adding the numbers for each of the three permission groups gives you the setting.
In our example, the owner is granted read, write and execute permission (7=4+2+1), whilst both the group and others are granted read and execute permission (5=4+1).

The read, write and execute permission settings have different meanings for folders than they do for files.
For a folder:
Read permission is required in order to list the files it contains.
Write permission is required in order to create, delete or rename files within it.
Execute permission is required in order to open files within it for reading and/or writing.

File permissions can be modified by most popular FTP programs, including WS_FTP and CuteFTP.

You can also check and update file permissions using the File Manager within your Control Panel. The permissions are displayed alongside all files and folders and can be changed by first clicking on the appropriate file name and then clicking "Change Permissions".

Return To Top of Page
  Useful Paths

Path to your CGI-Bin folder   /home/username/public_html/cgi-bin
Web address of your CGI-Bin folder
Web address of global CGI-Bin folder
Path to Sendmail /usr/sbin/sendmail
Path to Perl /usr/local/bin/perl
 (For convenience, /usr/bin/perl may also be used, so all Perl scripts should start either with the line #!/usr/local/bin/perl or with the line #!/usr/bin/perl)

Return To Top of Page
  Troubleshooting CGI Scripts
If your script doesn't work, please make sure that the Permissions are set right for both the scripts themselves, and any files or folders they need to access.

It is also worth double checking that all Paths are set correctly, and that all CGI scripts were uploaded as the correct File Type (usually "ASCII Text").

Another common problem is an output format error. Any output from a CGI program intended for a visitor's browser must be preceded by a valid "HTTP header". For example, if you are generating an HTML page, the first print statement that your program executes must be: print "Content-type: text/html\n\n";

Also, it is best to ensure that the very last line of a CGI script has a newline at the end. If not, it may not get processed when you run the script.

It can be a good idea to check your CGI scripts for syntax errors before uploading them to your site. To do this, you will need to download Perl from and install it on your local machine.
You can then type perl -c your_program.cgi in a DOS box to check your program for syntax errors.

You may also be able to learn more about why a CGI script is failing to work correctly by checking the Error Log in the Web Statistics section of your Control Panel.

Return To Top of Page
  Pre-installed CGI Scripts
Not only are you free to install your own or third party CGI scripts, we have also made a large number of pre-installed scripts available to you, including the following:

Visitor counterDate and/or time displayForm to Email (formmail)
GuestbookInternal site search engineBanner management (Entropy Banner)
Java clockCountdownRandom page content generation

Some of these scripts are always available in the global "CGI-Bin" folder (/cgi-sys). This is a shared folder which allows the same CGI files to be made available to all of our users.
Other scripts need to be set up before use and this can be easily done from within the CGI Script Centre in your Control Panel.

For more information on the various pre-installed scripts, please refer to the Pre-installed Scripts section of our Control Panel documentation.
  Further reading And Related Links
CGI Resources
CGI Directory
The Perl Homepage

Return To Top of Page
Home : Order : Plans & Prices : Domains : Demo : FAQ : Support : Feedback : Contact Us : Affiliates : Terms

Copyright © 2000-2004 Efficient Hosting. All rights reserved.
Reproduction in whole or in part is strictly prohibited.