debug cgi programs with post forms

D

david

Hi all,

How do i debug cgi programs where the html contains a post form ?
If it contains a get form it is easy because i can run perl -d from
the command line.
In this case i have a very large form with many variables and it is a
post form.
How can i debug it ?
I made a google search and found answers like printing the environment
variables and then run it like a get command with perl -d but this is
a bit tedious.
Is there a "best practice" for this type of problem ?


Thanks in advance,
David
 
S

sopan.shewale

Try using Data::Dumper module.

--------
use CGI;
use Data::Dumper;

my $query= new CGI();
print $query->header();
print Data::Dumper->Dump([$query]);

----------

This should give you all information into your browser.


-Sopan Shewale
(http://sopanshewale.blogspot.com)
 
S

smallpond

Hi all,

How do i debug cgi programs where the html contains a post form ?
If it contains a get form it is easy because i can run perl -d from
the command line.
In this case i have a very large form with many variables and it is a
post form.
How can i debug it ?
I made a google search and found answers like printing the environment
variables and then run it like a get command with perl -d but this is
a bit tedious.
Is there a "best practice" for this type of problem ?

Thanks in advance,
David


http://search.cpan.org/dist/CGI.pm/CGI.pm#DEBUGGING

CGI has a -debug mode that should allow you to emulate POST input
from
the command line. I haven't tried it, so I have no idea what it does
about the CONTENT_LENGTH stuff. The alternative would be to set
CONTENT_LENGTH and open a file of your POST data on STDIN.
 
X

xhoster

david said:
Hi all,

How do i debug cgi programs where the html contains a post form ?
If it contains a get form it is easy because i can run perl -d from
the command line.
In this case i have a very large form with many variables and it is a
post form.

Does it have file upload fields?
How can i debug it ?

What kind of bugs are you looking for?
I made a google search and found answers like printing the environment
variables and then run it like a get command with perl -d but this is
a bit tedious.
Is there a "best practice" for this type of problem ?

I find the best practice is not making bugs in the first place. :)

I also often add code to the CGI to process secret debugging parameter,
which turns on strategically placed extra print or warn statements.

warn "Now I'm doing $foo" if $cgi->url_param('debug');

If you really want to debug under -d, then you can run the program using
$cgi->save($file_handle) to save the query and then perl -d script.cgi <
saved_query_file

(this won't work with file upload fields, as the file contents are not
saved.)

Where the script use CGI has been changed to something like:
use CGI qw(-debug);

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
 
D

david

I am not using file upload fields, so the option of $cgi->save
($file_handle) to save the query and then perl -d script.cgi <
saved_query_file to run the query will be great

Thank you very much
 
D

david

Does it have file upload fields?


What kind of bugs are you looking for?


I find the best practice is not making bugs in the first place. :)

I also often add code to theCGIto process secret debugging parameter,
which turns on strategically placed extra print or warn statements.

warn "Now I'm doing $foo" if $cgi->url_param('debug');

If you really want todebugunder -d, then you can run the program using
$cgi->save($file_handle) to save the query and then perl -d script.cgi<
saved_query_file

(this won't work with file upload fields, as the file contents are not
saved.)

Where the script useCGIhas been changed to something like:
useCGIqw(-debug);

Xho

--
--------------------http://NewsReader.Com/--------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

I have now another problem. The $cgi->save($file_handle) does not save
cookie data. How it is possible to work with it when using also cookie
data ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top