2007-10-29
Debugging Perl CGI Scrips from the Command Line
For many Perl CGI developers it's always a pain to debug CGI scripts from the command line. Here is a quick way to help you:
That's it. At least for GET requests. For POST data you need to do the following: Put all your POST data in a file:
$ export HTTP_COOKIE="user_id=abc123"
$ export QUERY_STRING="month=jan&year=2001"
$ export REQUEST_METHOD="GET"
$ ./your-script.cgi
That's it. At least for GET requests. For POST data you need to do the following: Put all your POST data in a file:
recipient=John@Doe.com&Fullname=M+Name...and then set your environment like this:
$ export HTTP_COOKIE="user_id=abc123"...and then run your script:
$ export QUERY_STRING=""
$ export REQUEST_METHOD="POST"
$ ./scriptname.pl < postdata.txtHere are some additional links that you might find useful:
- http://www.thesitewizard.com/archive/servererror.shtml
- http://www.unix.org.ua/orelly/linux/cgi/ch15_03.htm