14.6 Debugging

Team-Fly    

 
Webmaster in a Nutshell, 3rd Edition
By Robert Eckstein, Stephen Spainhour
Table of Contents
Chapter 14.  The CGI.pm Module

14.6 Debugging

A complication of writing CGI scripts is that when debugging the script, you have to wrestle with the web server environment. CGI.pm provides support for debugging the script on the command line.

If you run the script on the command line without arguments, you will be placed into an "offline" mode, in which name -value pairs can be entered one-by-one. When you press CTRL-D, the script runs. For example:

 % birthday (offline mode: enter name=value pairs on standard input) birthday=6/4/65 ^D Content-type: text/html <P>Your birthday is 6/4/65.</P> 

You can also supply the name/value parameters directly on the command line:

 % test birthday=6/4/65 Content-type: text/html <P>Your birthday is 6/4/65.</P> 

Multiple values can be separated by spaces (as separate arguments on the command line) or by ampersands (as in URL-encoded syntax). In fact, you can use URL-encoded syntax on the command line. This makes it easy to supply raw CGI input to the script for testing purposes. Just remember to protect the ampersand from the shell. For example:

 % test 'birthday=6%2f4%2f65&name=Fred%20Flintstone' Content-type: text/html <P>Fred Flintstone, your birthday is 6/4/65.</P> 

Team-Fly    
Top


Webmaster in a Nutshell
Webmaster in a Nutshell, Third Edition
ISBN: 0596003579
EAN: 2147483647
Year: 2002
Pages: 412

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