in reply to LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts
If you have one method that works and one that appears the same but does not work then obviously the two methods differ in a vital detail.
Solution: find the difference. All you need to do is capture the output of your script (what it sends) and your manual method (what it sends) and compare the two say using diff. Ideally you want to capture exactly what goes down your modem/lan to be absolutely sure. Find the difference. Avoid speculation. Answer your own question.
It probably relates to your environment variables being different but you can find this out and I can only speculate. If you don't know how to dig into the internals of you system to do the capture a simple CGI script that spews the $ENV hash when you call it may well do the trick. Just call it both ways - it will ignore all your data any just spew the environment variables for you - if they don't match I'd start there.
Here is a quick script that should do the trick:
Added sub to escape the HTML properly as noted by merlyn Thought I may as well make it vomit forth all the CGI params as well just for good measure.
#!usr/bin/perl -w use strict; $|++; use CGI; my $q = new CGI; my @params = $q->param; my ($environment, $params); $environment .= " <tr><td>".escapeHTML($_)."</td><td>".escapeHTML($EN +V{$_})."</td></tr>\n" for keys %ENV; $params .= " <tr><td>".escapeHTML($_)."</td><td>".escapeHTML($q->para +m($_))."</td></tr>\n" for @params; print <<HTML; Content-type: text/html <html> <head> <title>Spew Entire CGI Environment</title> </head> <body> <h1>Environment Variables</h1> <table border='2'> <tr><td bgcolor="#C0C0C0">ENV VAR</td><td bgcolor="#C0C0C0">Value</t +d></tr> $environment </table> <h1>CGI Parameters</h1> <table border='2'> <tr><td bgcolor="#C0C0C0">Param</td><td bgcolor="#C0C0C0">Value</td> +</tr> $params </table> </body> </html> HTML sub escapeHTML { local $_ = shift; # make the required escapes s/&/&/g; s/"/"/g; s/</</g; s/>/>/g; # make the whitespace escapes - not required within pre tags s/\t/ /g; s/( {2,})/" " x length $1/eg; # make the brower bugfix escapes; s/\x8b/‹/g; s/\x9b/›/g; # make the PERL MONKS escapes (if desired) s/\[/[/g; s/\]/]/g; # change newlines to <br> if desired - not needed with pre tags # s/\n/<br>/g; return $_; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Dumping the CGI environment
by merlyn (Sage) on Sep 23, 2001 at 20:32 UTC | |
by tachyon (Chancellor) on Sep 24, 2001 at 06:38 UTC | |
by merlyn (Sage) on Sep 24, 2001 at 12:38 UTC | |
by tachyon (Chancellor) on Sep 24, 2001 at 13:23 UTC | |
|
Re: Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts
by merlyn (Sage) on Sep 24, 2001 at 19:19 UTC | |
by tachyon (Chancellor) on Sep 24, 2001 at 20:13 UTC | |
by merlyn (Sage) on Sep 24, 2001 at 20:17 UTC | |
by tachyon (Chancellor) on Sep 24, 2001 at 20:28 UTC |