Common CGI questions and problems

The most common problem that people have with cgi scripts is the permissions on the script. In order for a script to run, it must have execute permissions. If you are getting this error:

Forbidden

You don't have permission to access /cgi-bin/test.pl on this server.


You need to change the permissions to '755'. You can do this with most ftp clients, or through telnet.



The next most common problem is the 'mode' that you upload the script in. (i.e., from your editor to the server). You need to configure your ftp client to upload ".cgi" and ".pl" files in "ASCII" mode. The error you will recieve if you do not upload in ASCII mode is:

Internal Server Error

Premature end of script headers: /home/you/cgi-bin/script.cgi



 

How to check for syntax errors in a script.

1. Log into your account through telnet, rlogin, or ssh. (see above)
2. Assuming your script is in 'cgi-bin', type "cd www/cgi-bin", hit enter.
3. Type "perl scriptname.cgi" where 'scriptname.cgi' is the name of the script.
4. Perl will tell you what is wrong with the script. Make the recomended changes.