cgihead.gif (3272 bytes)


cgiinstallerhead.gif (3724 bytes)


Quick Reference Tables

Program Locations for CGI Scripts
perl /usr/bin/perl
send mail /usr/sbin/sendmail
date /bin/date
Other Neccessary Locations
CGI directory
server location
/users/username/cgi/
OR
/users/username/cgi-bin/
Unix File Permissions for Scripts
CGI Scripts (Executable) chmod 755 filename
Read and Written-to files chmod 766 or 777 filename
Read-only files chmod 744 filename
Read, Write, Execute chmod 777 filename

Frequently Asked Questions

What is CGI?
CGI stands for Common Gateway Interface, and it is a way for communication between the web server and the web browser. CGI scripts are most commonly are programmed in Perl, C, and C++.

 

What do they do?

CGI scripts are written to perform basic tasks with the server, using form input from a web browser or a server side include. The most common use is processing forms. CGI scripts can take input from a form, and output it back to the web browser, write it to a log file, or use it to send an email. CGI scripts can redirect users to a new page, send email, count hits, add to databases, keep an automated list of visitors, display random images, etc.

How can I use CGI Scripts?
Go to the CGI Scripts section in the Developer Resources . Then, find a script that you would like to use. Copy it to your computer for making necessary changes. Then, you'll need to upload it to your web space, and make the permission changes. For more detailed information, read further.
 

How do I get these things to work!!

CGI scripts are not as simple as they seem. All it takes is one minor mistake in the code, the wrong file permissions, or even the wrong uploading method for the program to fail. It takes a little patience to get scripts working, but after setting up one, you'll find that it gets easier with time.

How should I upload CGI scripts?
FTP CGI scripts to your cgi directory.
NOTE: Uploading CGI Scripts as ASCII is most important.

Remember to upload all .cgi files in ASCII mode, not binary, otherwise the program will give you a Server 500 Error. This includes .html files in which the scripts write to. Make sure the executables have .cgi extension on them, not .pl.

Then, telnet to your cgi directory and change permissions on the files. An easy way for changing file permissions directly through an FTP client is with CuteFTP.

What is the path to the Perl interpreter?
Perl 5 is at /usr/bin/perl5 . So the first line of all of your Perl scripts should be:

#!/usr/bin/perl5

How can I find the path to interpreters for other CGI scripting languages?
To find the path to a scripting language interpreter, you can use the whereis command. If the interpreter is in your default path, the whereis command will give you the path to it. Syntax:

whereis interpreter_name [enter]

Troubleshooting

Why isn't my CGI program working?
Go through the following troubleshooting checklist and procedures to isolate the problem:
Execute it from the command line of a telnet session. For instance, if your cgi program is in your cgi directory type the following.

cd cgi-bin
./filename.cgi

If you get output that looks like,

filename.cgi: Permission denied.

then you need to change the permissions on your program so that it is executable by the server.

If you get other errors, such as syntax errors, then you need to debug your code. The following steps may help you do that.

Check the syntax. If your script is written in Perl, you can check your script for any syntax errors by typing the following:

cd cgi-bin
perl5 -c filename.cgi

Check the .cgi or.plextension. Our server will only serve files with the .cgi or .pl extension as CGI programs. If necessary, you can rename the file with the mv command:

mv old_filename new_filename

Check the source file's language. The program must be written in a language that we support. If the language requires an interpreter, you should check to make sure the path you have provided to the interpreter is correct.

Check the permissions. First read our guide to permissions. Make sure that the file is executable. To check file permissions type:

ls -l

All CGI programs must be of permission 755. Do this by using the chmod command:

chmod 755 filename

All files written-to by your program must be of permission 766 or 777. Do this using the chmod command:

chmod 766 filename

All programs REQUIRED, INCLUDED, or referenced by your program must be of permission 755. If your scripts are in a subdirectory of your cgi directory, make sure that the subdirectory is of permission 755, too. If your script writes output to a file, you may find it convenient to make the program setuid with the following command:

chmod u+s filename

Check your paths.
Make sure that all the file paths and references in your CGI script are pointing to the right places. If the script references your own function library, remember to INCLUDE it appropriately into your code. Also, remember that UNIX is case-sensitive, so make sure the directories and filenames match case.