San Francisco State University
CGI Troubleshooting Tips
"CGI is an abbreviation for Common Gateway Interface. It is a specification for transferring information between a World Wide Web server and a CGI program. A CGI program is any program designed to accept and return data that conforms to the CGI specification. The program could be written in any programming language, including C, Perl, Java, or Visual Basic."
"CGI programs are the most common way for Web servers to interact dynamically with users. Many HTML pages that contain forms, for example, use a CGI program to process the form's data once it's submitted. Another increasingly common way to provide
dynamic feedback for Web users is to include scripts or programs that run on the user's machine rather than the Web server. These programs can be Java applets or Java scripts. These technologies are known collectively as
client-side solutions, while the use of CGI is a server-side solution because the
processing occurs on the Web server."
Definition taken from the
PC Webopædia Dictionary
This document provides answers to some of the most common CGI errors and questions. Examples are noted with a pencil image -
.
If the solutions below do not resolve a problem you are experiencing, please contact the Web Team. In your message, include the CGI source code, the URL where the CGI is located, and/or any error messages.
CGI Documentation Overview
To illustrate how the errors occur, we will use a simple CGI program called "Hello World" stored in an account called 'weber'.
The "Hello World" cgi script contains the following lines:
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<html>";
print "<head>";
print "<title>Test</title>";
print "</head>";
print "<body>";
print "<h1>Hello World</h1>";
print "</body>";
print "</html>";
When the "Hello World" cgi script runs successfully, it produces this page.
Common CGI Errors
If you are getting an error message or if you are experiencing problems other than the ones listed below, please contact the Web Team. In your message, include the CGI source code,
the URL where the CGI is located and/or any error messages.
This server can only be used to deliver SFSU faculty web pages. SFSU staff and student personal homepages can be accessed from http://userwww.sfsu.edu/~userid, where userid is the account name (E-mail address) of the individual whose page you would like to see."
the document you request may have moved, been renamed, or doesn't exist. Please try searching for the document using the Search link listed below."
Solution:
Reference the cgi web page to use host online instead of userwww.
"Hello World" Example:
In our example, the "Hello World" cgi script is located in the SFSU Internet Account weber's public_html directory. View the "Hello World" cgi script
at http://online.sfsu.edu/~weber/hello.cgi not http://userwww.sfsu.edu/~weber/hello.cgi
Return to top | Return to Common CGI Errors
the document you request may have moved, been renamed, or doesn't exist.
This server can only be used to deliver SFSU faculty web pages. SFSU staff and student personal homepages can be accessed from http://userwww.sfsu.edu/~userid, where userid is the account name (E-mail address) of the individual whose page you would like to see."
Example:
If you were looking for the homepage of pjones@sfsu.edu you would enter:
http://userwww.sfsu.edu/~pjones
To locate account names please use the SFSU Finger gateway."
Solution:
Set Execute permissions on the CGI file or review the Permissions section.
"Hello World" Example:
|
|
Return to top | Return to Common CGI Errors
"Server Error:
This server has encountered an internal error which prevents it from fulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log."
This is a generic error message which usually means that your CGI could not execute properly.
Solution(s):
"Hello World" Example:
Solution #1:
See Wrong permissions
|
|
Solution #2:
See Wrong Perl Interpreter Path.
"Hello World" Example:
We know that the perl interpreter path on the online server is located in:
/usr/local/bin/perl
The code, therefore, should look like the following:
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<html>";
print "<head>";
print "<title>Test</title>";
print "</head>";
print "<body>";
print "<h1>Hello World</h1>";
print "</body>";
print "</html>";
Solution #3:
See "Error in the CGI code"
Return to top | Return to Common CGI Errors
Solution(s):
"Hello World" Example:
Solution #1:
View the "Hello World" cgi web page at http://online.sfsu.edu/~weber/hello.cgi not http://userwww.sfsu.edu/~weber/hello.cgi
Solution #2:
Using an FTP program like WS_FTP or Fetch, rename hello.pl to hello.cgi script.
Return to top | Return to Common CGI Errors
Solution:
To find out what permissions it requires, review the documentation or readme file that came with your CGI script/program.
See the Detailed information on permissions section for instructions on how to set permissions or contact the
Web Specialist for assistance.
Return to top | Return to Common CGI Errors
Solution(s):
"Hello World" Example:
Solution #1:
View the "Hello World" cgi web page at http://online.sfsu.edu/~weber/hello.cgi not http://userwww.sfsu.edu/~weber/hello.cgi
Solution #2:
Using an FTP program like WS_FTP or Fetch, rename hello.pl to hello.cgi script.
Return to top | Return to Common CGI Errors
Solution:
Determine where the Perl Interpreter path is located on your server
Example:
|
|
Return to top | Return to Common CGI Errors
Error in the CGI or Perl code
Solution:
Review the code for extra or missing quotes, spaces, wrapped text, semicolons, etc. If you can't find the error, overwrite the script with an original copy. Any changes you made to the script will need to be redone.
Note: You will lose any changes you made to the CGI script.
Return to top | Return to Common CGI Errors
CGI script not designed for Solaris 2.6
Solution:
Check the documentation that came with your CGI script to make sure the script can be run on a Solaris 2.6 system. It must run on a Solaris 2.6 system in order for it to work on our server.
Return to top | Return to Common CGI Errors
The CGI requires an additional Perl script to work
Solution:
Check the CGI documentation to find out where to obtain the Perl script. If it requires a Perl script, copy the Perl script to a directory in your Internet Account, rename it with a .cgi extension and check the permissions. The CGI documentation
should provide instructions on how to save the Perl script and what permissions to set.
Return to top | Return to Common CGI Errors
Setting File Permissions on host online
Host online uses the Andrew File System (AFS). This is different from most UNIX servers. The AFS system sets permissions on a per-directory basis. It is possible to use regular UNIX file permission commands on host online but they will have little
or
no effect. The only regular UNIX file permissions you will need to set it ths 'x' - execute permission on the file(s) with a .cgi extension. If your cgi requires permissions to write to a file or to create new files you will need to set ACL's which
are Access Control Lists.
Understand the risks
Setting permissions that allow any user to write to a file carries some risk - anyone can delete the contents of the file or post their personal manifesto. To avoid putting your non-cgi web files at risk keep all files that need to
be written to by a cgi in separate directories.
How to set execute permissions
All .cgi files need to have the execute permission set.
"Hello World" Example:
|
|
Return to top | Return to Common CGI Errors
How to set write permissions
Any cgi that updates a file in your account needs to have write permission set on the directory where the file(s) is stored.
"Hello World" Example:
|
|
Return to top | Return to Common CGI Errors
How to set insert permissions
Any cgi that creates files in your account needs to have insert permissions set on the directory where the file(s) is stored.
"Hello World" Example:
|
|
Return to top | Return to Common CGI Errors
Three positions: XYZ
X=owner(you)
Y=group
Z=others (this is how web users are seen by the system)
| Permission Number | Permission Set | Permission Letter(s) |
| 0 | No Permissions Set | N/A |
| 1 | Execute | x |
| 2 | Write | x |
| 3 | Write, Execute | w,x |
| 4 | Read | r |
| 5 | Read, Execute | r,x |
| 6 | Read, Write | r,w |
| 7 | Read, Write, Execute | r,w,x |
Sample Scenario:
The directions say to chmod the cgi script: 666
What it means: Read already set by default
What to do: Set write permissions
"Hello World" Example:
|
|
Sample Scenario:
The directions say to chmod the cgi script: 777
What it means: Read already set by default
What to do: Set write and execute permissions
"Hello World" Example:
|
|