stevelake has asked for the wisdom of the Perl Monks concerning the following question:

I have used this script to post information on a unix based site and it worked perfect, now that im running it at home on win xp professional using activeperl 5.8 the query string doesnt seem to work right. What is different or what do I need to change in the script to work on winxp platform the same? Im getting the page response in the browser but the SITE being fetched is stating IM NOT sending any of the information (i.e. posted query string info). IT IS NOT a server error 500 , it is just the info not going thru.
some of the script here:
#!c:/Perl/bin/perl use CGI; use HTTP::Headers; use HTTP::Request; use LWP::UserAgent; $q = new CGI; $blankthing = ""; #set inital $pictureurl = $q->param('pictureurl'); $picturedesback = $q->param('picturedes') || $blankthing; #put into va +r $picturedes = $picturedesback; $picturedes2 = $picturedesback; $altpicturedes = substr($picturedes2, 0,39);# = ""; #cut off after 79 + charactors $bannerurl = "http://www.blah.com/banner.gif"; $siteurl = "http://www.blah.com/"; $bannertext = "blah"; $email = "webmaster\@blah.com"; $reclink = 'http://www.blah.com/'; $counterthing = $q->param('whatsite'); $beginpicurl = "www.blah.com"; if ($counterthing eq 1) { $counterthing = $counterthing + 1; $posttourl = "http://www.blah.com"; $refererurl = "http://www.blah.com"; $beginpicurl = "www.blah.com"; $q = new CGI( { PictureURL=>"http://". $beginpicurl . "/" . $pictureurl, PictureDescription =>$picturedes, BannerURL=>$bannerurl, SiteURL=>$siteurl, BannerText=>$bannertext, Email=>$email, Reciprocal=>$reclink, action=>"SendNow", }); &dothething; } elsif ($counterthing eq 2) { $counterthing = $counterthing + 1; $posttourl = "http://blah.com"; $refererurl = "http://blah.com"; $q = new CGI( { purl=>"http://$beginpicurl/$pictureurl", desc =>$picturedes, surl=>$siteurl, burl=>$bannerurl, fnct=>"add_account", }); &dothething; } elsif($counterthing eq 3) { print $q->header; print "all done click back"; exit; } else{ print $q->header; print "ERROR"; } sub dothething { $formdata = $q->query_string; $h = new HTTP::Headers( Accept=>'text/html, text/plain, image/*', Referer=> $refererurl, Content_Type=>'application/x-www-form-urlencoded', Content_Base=>$posttourl, User_Agent=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x + 4.90)", ); $req = new HTTP::Request( POST, $posttourl, $h ); $req->content_type('application/x-www-form-urlencoded'); $req->content($formdata); $ua = new LWP::UserAgent( agent=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90 +)", ); $response = $ua->request($req); $JSCRIPT=<<END; function nexturl() { window.parent.location = "http://blah.com/"; } setTimeout("nexturl()", 15000); END print $q->header; print $q->start_html(-script=>$JSCRIPT); print "<BASE href=$posttourl>"; print $response->content; #print $q->end_html; }

20060130 Janitored by Corion: Added <readmore> tag

20060131 Edited by planetscape - removed spurious whitespace

Replies are listed 'Best First'.
Re: script help (worked well on unix but NOT on winxp) newbie
by brian_d_foy (Abbot) on Jan 30, 2006 at 00:02 UTC

    Have you verified that you're sending what you think your sending? Sniff the traffic to make sure. You can also dump $req to ensure it is what you think it is.

    You might also want to check out WWW::Mechanize which would do most of this for you. You seem do be doing a lot of the work the hard way.

    Can you clarify what your setup is? You have this script POSTing to another CGI script. Are they running on the same server? Which one changed? Does the script still work from a unix machine? Have the module versions or the perl version changed in the process? What happens when you connect to the CGI script manually and send the same thing?

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
      yes,Im sending the info to a form at another URL. the names are perfect and YES, it worked on UNIX based server perfect.

      this is what i get as a response content (this was copied/paste as it looks identical below(note* the bannertext on the same line): it appears to take the reclink variable but nothing else, I know the problem lies in my code not the site im retrieving.

      ********start cut***************
      Submission Error

      You did not fill out all of the fields. Please use your back button to complete the form Reciprocal=http://www.blah.com/;BannerText
      Description=
      PictureURL=
      Email=
      SiteURL=

      ********end cut***************

      here's what i get when i dump $req on the retrieved page:

      ********start cut***************

      Reciprocal=http%3A%2F%2Fwww.blah.com%2F;BannerText=blah;BannerURL=http +%3A%2F%2Fwww.blah.com%2Fbanner.gif;PictureDescription=My%20blah%20bla +h;SiteURL=http%3A%2F%2Fwww.blah.com%2F;PictureURL=http%3A%2F%2Fwww.bl +ah.com;action=SendNow;Email=webmaster%40blah.com
      ********end cut***************

      Janitored by Arunbear - added code tags around long line.

        It looks like you have a GET request URL stored in Reciprocal. I also note that URL is using ';' as a delimiter which, while appropriate and standard, causes confusion for some scripts. You might have a newer version of a module on the new box.

        <-radiant.matrix->
        A collection of thoughts and links from the minds of geeks
        The Code that can be seen is not the true Code
        I haven't found a problem yet that can't be solved by a well-placed trebuchet