Perl / CGI Scripts


Paths:

Our server path to PERL is:
/usr/bin/perl

The path to the Sendmail program is:
/usr/sbin/sendmail


Installing and running CGI scripts:

Before uploading your CGI script to the server, you must first be sure that it is configured to work properly with the particular server on which it will be installed. The first configuration option that you'll need to address is the line that deals with the location of the PERL executable. If you open your CGI script with a text editor, you will find this line, sometimes referred to as the "shebang" line, at or very near the top of the script. Since our PERL binary is located in the /usr/bin directory, your shebang line should look like this:
#!/usr/bin/perl

Once you have successfully configured yourl CGI script, upload it to your site's /var/www/cgi-bin directory. CGI scripts must be uploaded in ASCII (text) mode or else they may fail to work!


File permissions for CGI scripts:

CGI's must be set with executable file permissions or else requests for the script from the web server will result in the dreaded Internal Server error. Scripts that need to be executable should have their permission set with chmod 755. This sets the file's permissions so that the file's owner may read, write, and execute the file, and anyone else can only read and execute it.

Troubleshooting:

By default, TMX provides each site admin with a pre-installed script to help with CGI installation and troubleshooting issues. This script, called tmx_env.cgi, is located in your site's cgi-bin, and provides domain configuration information, including paths and installed modules

To verify the operation of your site's cgi-bin, as well as to display important path and configuration info, type the following from your browser:
http://www.yourdomain.com/cgi-bin/tmx_env.cgi
This should return a list of various configuration parameters. If it does, this indicates that your cgi-bin is working and that the trouble lies elsewhere. If it does not, please contact TMX support and we will correct it.

The overwhelming majority of cgi script problems can be traced to one of the following:

  1. Incorrect shebang line
  2. Script uploaded in binary mode instead of ASCII (text) mode
  3. Incorrect script permissions
  4. Improper line wrapping

File and Directory Permissions Explained
There are three levels of file permissions: read, write and execute.  In addition, there are three groups to which you can assign permissions: file owner, user group and everyone.  The command chmod followed by three numbers is used to change permissions.  The first number is the permission for the owner, the second for the group and the third for everyone.  Here are how the levels of permission translate:

0 = --- No permission
1 = --X Execute only
2 = -W- Write only
3 = -WX Write and execute
4 = R-- Read only
5 = R-X Read and execute
6 = RW- Read and write
7 = RWX Read, write and execute

 

To change permissions using FTP, perform the following steps:

1- Open the WSFTP program and connect to your web site.

2- Select the file or the directory on which you want to change permissions.
3- Click your right mouse button to activate the pop up menu.
4- Select "chmod (UNIX)". A "Remote file permissions" window will appear.

ftp commands pop up window ------- Remote file permissions checkbox window

5- Select the attributes that you want to set to the file or directory.
6- Select ok. You have now changed the permissions.
7- You can check the permission settings by clicking the Refresh button and then clicking the DirInfo button .

 

Additional Information:

The Common Gateway Interface
NCSA provides much helpful information about CGI here (along with a good introduction to forms.)

Server-side includes

Also known as "parsed HTML": what they are, how they work, how to use them.


Using ISINDEX for server-side searches

This explains how to write a CGI script to perform simple text searches on your web server.