Troubleshooting CGI Programs
CGI programs launched from a web server run under a fundamentally different environment than they do when invoked from the command line. While you should always verify that your CGI program runs properly from the command line,[109] this isn’t enough to guarantee that your program will work when called from the web server.
You should get the CGI programming FAQ and a good book on CGI
programming to help you in this. Some of these references are listed
at the end of this chapter. Here’s a brief list of the frequent
problems that arise in CGI programming. Almost all of them trigger
those annoyingly unhelpful 500 Server Errormessages that you will soon come to know and hate.
If, when sending HTML to a browser, you forget the blank line between the HTTP header (that is, the Content-Type line) and the body, your program won’t work. Remember to output a proper Content-Type line (and possibly other HTTP headers) plus a totally blank line before you do anything else.
The server needs to be able to read and execute the script, so you need to make sure that whatever user your script runs as (e.g., IUSR_MYSERVER under IIS) has read and execute rights to the script.
The directory where the script resides must have read and execute rights for the script user.
The script must be installed in the proper directory for your server configuration. For example, on some systems, the directory may be c:\inetpub\scripts.[110]
You need to have your script’s filename end in a particular ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access