
Debugging CGI ScriptsThe examples on this page discuss common errors experienced when running CGI scripts through cgiwrap on an ITS UNIX Web server. Most of the troubleshooting steps require the Web publisher to logon to the Web server ("uts.cc.utexas.edu" or "ccwf.cc.utexas.edu") and make $HOME/public_html/cgi-bin the current working directory. CGIWrap Error: Script File Not Found!This error indicates that the server could not find a file in a link, the browser location, or the ACTION attribute of a FORM tag.
CGIWrap Error: Execution of this script not permittedThis error message indicates that the permissions on the CGI script file are set incorrectly. The file must be world-readable and world-executable but not group or world-writeable in order to run through cgiwrap.
Internal Server ErrorYou can troubleshoot the problem with the cgiwrap debugging feature called cgiwrapd. You can enable cgiwrapd by replacing "cgiwrap" with "cgiwrapd" in the cgiwrap URL. http://server/cgi-bin/cgiwrapd/username/scriptname The errors in the examples below were generated by including mistakes in the script "helloworld.cgi" as run by the user "twmaint" on the server "uts.cc.utexas.edu." The debugging URL for this script is: http://uts.cc.utexas.edu/cgi-bin/cgiwrapd/twmaint/helloworld.cgi The part of the resulting screen important to debugging most CGI scripts is the part starting with: Output of script follows: The cgiwrapd output from the "helloworld.cgi" script should show: Output of script follows: A common error is to not separate the HTTP header (Content-type: text/plain) from the body (Hello World!) with a blank line. The cgiwrapd result from this error looks like this: Output of script follows: To fix this problem, make sure that the script prints two newline characters, "\n\n" after the "Content-type: text/plain" header. Using the line: print "Content-type: text/plain\n\n"; in your script should fix this problem. When borrowing code for use on ITS servers from scripts in use on other servers, a common error is to have an incorrect path to Perl in the first line of the script. This is indicated by no script output listed in cgiwrapd: Output of script follows:To solve this problem, make sure the first line of the script is: #!/usr/local/bin/perl This error is also caused when a borrowed script is uploaded to the server using the "binary" transport method in an FTP program such as WS_FTP for Windows. If this was the cause of the problem you can fix it by uploading the file again using the "ASCII" transport method, or you can edit the file on the server to remove the control character from the end of each line. Another common error is a syntax error in the Perl code for the CGI script. In this example, a semicolon is missing from the end of the third line: Output of script follows: If you get this error from any of the scripts in this tutorial, double-check to make sure you have copied the source of the Perl script exactly, for all of these scripts have been tested on UTS. These errors are usually caused by incorrect Perl code. If the error you saw was not listed on this page, and you are unable to find the solution on your own, help is available through www@www.utexas.edu. Include your UNIX username, the cgiwrap URL you are using, the name of the server you are using, and the text of any error messages you are seeing in your message. |