Debugging a CGI Script

CGI programs are debug resistant. Frequently, you’ll get only the message "Internal Server Error" on the screen with no clue as to what happened. Also, the old trick of putting print statements through your code won’t work. You don’t have a screen to print to. This section looks at the various bugs that can occur and how to deal with them.

Getting Past “Internal Server Error”

Suppose that you are trying to execute a CGI script and the server returns a screen titled "Internal Server Error" or "Forbidden". This indicates that your CGI script could not be run or that it returned something that confused the server.

To take care of this problem, you should check the following:

  1. Try checking the syntax of your program with the command:

    perl –wcT script.pl
  2. Make sure that your program is executable and readable by everyone. Remember that the server will be executing the script, not you. That means that the Linux/UNIX user who executes the account is not you.

    3. If possible, check the server’s error log to see what just happened. If you are using the most common web server, Apache, then the default location of the log file is /var/log/httpd/error_log. (Again, this is system/ installation dependent.)

If this fails, you can try running the program manually or get additional help from your server administrator. This will help you to get past most “software errors” that your script can generate.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset