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:
$ 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"
$ export QUERY_STRING=""
$ export REQUEST_METHOD="POST"
...and then run your script:
$ ./scriptname.pl < postdata.txt
Here are some additional links that you might find useful:
Have fun hacking...

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?