My first perl script... can one can help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xxxman2
    Registered User
    • May 2003
    • 61

    #1

    My first perl script... can one can help!

    Hi , I am newbie, I just wrote my first script, but it's doesn't work, the error message is "500 Internal Server Error".
    My script calls a script on other server, any ony can help to find out what's error,
    I really appreciate your help, thank you!

    -----------------------------------------------
    #!/usr/bin/perl

    $siteid= 'xxxx';
    $sitepass= 'xxxx';
    $lognm= "xxxx";
    $passfile= 'xxxx';
    $webemail= '[email protected]';
    $sitename= 'xxxx';
    $contenturl = 'http://www.contenturl.com/';
    $webid = $siteid;
    $webfile = 'xxxx';
    $reqtype = 'XXXXX';
    $username=$FORM{'username'};
    $password = $FORM{'password'};
    $email= $FORM{'email'};


    sub readduser () {
    my $addscript = 'http://www.otherserver.com/cgi-bin/add.cgi';
    my $query = "siteadd=all&"."webfile=".$webfile."&"."reqtype=". $reqtype."&"."webid=".$webid."&"."passfile=".$pass file.
    "&"."webemail=".$webemail."&"."sitename=".$sitenam e."&"."lognm=".$lognm."&"."expire=999999999&"."con tenturl=
    ".$contenturl."&"."paymentmethod=".$sitename."&"." eml=".$email."&"."username=".$username."&"."passwo rd=".$password;
    my $h = new HTTP::Headers;
    $h->referer("http://www.mydomain.com/cgi-bin/");
    $h->user_agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461; .NET CLR 1.0.3705)');
    $h->authorization_basic($siteid, $sitepass);
    my $req = HTTP::Request->new(POST => $addscript, $h);
    $req->content_type('application/x-www-form-urlencoded');
    $req->content($query);

    my $ua = LWP::UserAgent->new;
    my $res = $ua->request($req);
    my $result = $res->as_string;
    if ($result =~ /added/si) {
    print "[$key] readded.\n";
    }
    }
    ----------------
    Last edited by xxxman2; 05-31-2003, 10:41 PM.
  • mrthumbs
    salad tossing sig guy
    • Apr 2002
    • 11702

    #2
    the script should work.
    However it will generate an error when requesting it
    through your browser since there is no output defined.

    Comment

    • Hell Puppy
      Confirmed User
      • Oct 2002
      • 183

      #3
      Two tips:

      1) first output to the browser from any perl cgi script needs to be something like this:

      print "Content-type: text/html\n\n";

      2) when you get a 500 error in the browser, go look at the webserver's error log. it'll usually tell you what the perl error was including the line number.

      Comment

      Working...