Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > debug cgi programs with post forms

Reply
Thread Tools

debug cgi programs with post forms

 
 
david
Guest
Posts: n/a
 
      11-20-2008
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
 
Reply With Quote
 
 
 
 
sopan.shewale@gmail.com
Guest
Posts: n/a
 
      11-20-2008
Try using Data:umper module.

--------
use CGI;
use Data:umper;

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

----------

This should give you all information into your browser.


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




On Nov 20, 2:38*pm, david <(E-Mail Removed)> wrote:
> 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


 
Reply With Quote
 
 
 
 
smallpond
Guest
Posts: n/a
 
      11-20-2008
On Nov 20, 4:38 am, david <(E-Mail Removed)> wrote:
> 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.


 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      11-20-2008
david <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
david
Guest
Posts: n/a
 
      11-20-2008
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

On Nov 20, 6:27*pm, (E-Mail Removed) wrote:
> david <(E-Mail Removed)> wrote:
> > 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.


 
Reply With Quote
 
david
Guest
Posts: n/a
 
      12-09-2008
On Nov 20, 6:27*pm, (E-Mail Removed) wrote:
> david <(E-Mail Removed)> wrote:
> > Hi all,

>
> > How do idebugcgiprograms 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 idebugit ?

>
> 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 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 ?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debug CGI with complex forms Sullivan WxPyQtKinter Python 1 04-08-2006 04:22 PM
forms authentication -- expired forms cookie vs. not provided forms cookie Eric ASP .Net Security 2 01-27-2006 10:09 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM
1) How to debug CGI.pm cookies 2) Template.pm with CGI.pm Mr I Perl Misc 13 09-30-2003 01:06 AM
ASP, FORMS, POST METHOD And Post with out form(???) Don Glover the younger ASP General 0 07-13-2003 02:47 AM



Advertisments