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.

Update

Here is a quick script that should do the trick:

Update2

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/&/&amp/g; s/"/&quot;/g; s/</&lt;/g; s/>/&gt;/g; # make the whitespace escapes - not required within pre tags s/\t/&nbsp;&nbsp;&nbsp;&nbsp;/g; s/( {2,})/"&nbsp;" x length $1/eg; # make the brower bugfix escapes; s/\x8b/&#139;/g; s/\x9b/&#155;/g; # make the PERL MONKS escapes (if desired) s/\[/&#091;/g; s/\]/&#093;/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


In reply to Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts by tachyon
in thread LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts by dumbadam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.