 |
UPOINT:: CGI Scripts: FAQ |
Title: General Help: 12 most commonly-made CGI mistakes The most common CGI mistakes made by our users.
1) Incorrect perl executable path
The first line in the script should be #!/local/bin/perl, and the standard variations #!/usr/bin/perl and #!/usr/local/bin/perl are also supported. This is usually a problem with those coming from NT Systems.
2) The @ sign problems
Not back-slashing the @ symbol in email addresses. Most of the time your email address in the configuration part should appear as "yourname\@domain.com" and NOT "yourname@domain.com".
3) The double quotation mark problems
Forgetting to backslash the double quotation marks (") in a statement. This error might happen after a user modified the script and he left out the semicolon. Please see example above.
4) The missing semicolon
Forgetting to close statements with a semicolon (;). This error might happen after a user modified the script and he left out the semicolon. The Perl statement usually appears as:
PRINT "<p>My Website Title Here</font></p>\n";
PRINT "<p>Welcome to my site ...</font></p>\n";
5) The CHMOD problems
Not marking the script executable. UNIX requires that you chmod (change mode) the script so that it is executable. In other words, you must give people trying to run the script, either from a browser or through the command line to run it on that server. Scripts should be chmoded to 755 (rwx-r-x-r-x). Directories/folders should also be chmoded to 755 if there are scripts being executed in them. Directories being written to should be chmoded to 777 in most cases. (files being written to should be chmoded 777 or 666 - whatever works for you). In some servers, you have to keep the folder at 755 (instead of the recommended 777) to make it writable and executable.
6) Incorrect script extension
The extension of cgi scripts are usually *.cgi or *.pl. Some servers are not configured to recognize *.pl as an executable script. In this case, you need to rename the script with a *.cgi extension.
7) Wrong configuration of PATH
Most scripts require you to set the PATHs (not URL) to another scripts, the data files, the templates etc. Please make sure that the paths are correct.
8) Upload at wrong mode
You should always upload scripts, data files and other text files in ASCII mode. Images should be uploaded in BINARY mode. Most FTP clients are smart enough to do this automatically unless they are accidentally configured not to.
9) Missing Content-Type header
This error might happen after a user modified a script and he accidentally erased the header. CGI scripts must print a Content-Type header followed by a blank line if the result is to be shown as a HTML page. The quick way out in perl is print "Content-Type: text/html\n\n";
10) Missing # sign
The # signs are used in Perl scripts to uncomment a line. Lines started with # is ignored by the server. Example
# This is a reminder line
If the # sign is missing, an error is expected.
11) SSI problems
Remember that all SSI files should have an extension of ".shtml"
12) Tweaking the script too early
Unless you are a real expert, please follow the steps in instruction file that comes with the script. You shall only start tweaking the script (if really needed) once everything is working fine.
Powered by Document Publisher |
|
 |