C.5 Log Files

Error Logs and STDERR

Normally, error messages are sent to the terminal screen ( STDERR ) when something goes wrong in a Perl script, but when launched by a server as a CGI script, the errors are not sent to the screen, but to the server's error log file. In the browser you may see "Empty Document" or "Internal Server Error," which tells you nothing about what went wrong in the program.

Always check your syntax at the shell command line with the -c switch before handing the script to the server. Otherwise, you will not see your error messages unless you check the log files. Check the syntax of your Perl scripts with the -c switch.

Example C.7
 (At the Command line) 1  perl -c perlscript  2   perlscript syntax OK 
Example C.8
 (Perl syntax errors shown in the Apache server's error log)     [Mon Jul 20 10:44:04 1998] access to /opt/apache_1.2b8/        cgi-bin/submit-form failed for susan, reason: Premature end        of script headers     [Mon Sep 14 11:11:32 1998] httpd: caught SIGTERM, shutting down     [Fri Sep 25 16:13:11 1998] Server configured -- resuming normal          operations 1  Bare word found where operator expected at welcome.pl line 21,   near "/font></TABLE"  (Missing operator before TABLE?) 2  syntax error at welcome.pl line 21, near "<TH><"  syntax error at welcome.pl line 24, near "else"     [Fri Sep 25 16:16:18 1998] access to /opt/apache_1.2b8/         cgi-bin/visit_count.pl failed for susan, reason:         Premature end of script headers 

Access Logs and Status Codes

Check your server's access log to see what status codes were sent by your server after a transaction was complete. [3] The following example consists of excerpts taken from the Apache server's access log. This log reports information about a request handled by the server and the status code generated as a result of the request.

[3] For more detailed information on status codes, see www.w3.org/Protocols/HTTP/HTRESP.html

Table C.6. HTTP status codes.


Message Code




Success, OK


No Content


Document Moved


Bad Request






Not Found


Internal Server Error


Not Implemented


Service Unavailable

Example C.9
 (Status codes from the Apache server's access log) 1  susan - - [08/Oct./1999:10:45:36 -0700]   "GET /cog-bin/visit_count.pl HTTP/1.0" 500  388 2   susan - - [08/Oct./1999:10:45:59 -0700]     "GET /cgi-bin/visit_count.pl HTTP/1.0"  200  426 

JavaScript by Example
JavaScript by Example (2nd Edition)
ISBN: 0137054890
EAN: 2147483647
Year: 2003
Pages: 150
Authors: Ellie Quigley

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net