in reply to Re: Getting past a password prompt in perl
in thread Getting past a password prompt in perl

I have something close to that but not getting through....imagine it is something to do with my credentials statement but i know the user/pass combo works

use WWW::Mechanize; use HTTP::Request; sub httprequest { my $mech = WWW::Mechanize->new(autocheck => 1); $mech->credentials("servername:8082", "Tomcat Manager", "username", "p +assword"); $mech->get("http://servername:8082/manager/status/all"); print $mech->content();

$ perl to*

Error GETing http://stltcat04:8082/manager/status/all: Unauthorized at tomcatQA.pl line 13

Replies are listed 'Best First'.
Re^3: Getting past a password prompt in perl
by missingthepoint (Friar) on Feb 08, 2009 at 04:28 UTC

    Are you posting the actual code you're running (presumably tomcatQA.pl)? If not, please do.

    Maybe try the following (add before your print $mech->content()) and post the output here?

    use Data::Dumper; print Dumper $mech->response; # dump returned HTTP::Response object

    One other thing - you don't need to explicitly use HTTP::Request because WWW::Mechanize will use it for you.


    Life is denied by lack of attention,
    whether it be to cleaning windows
    or trying to write a masterpiece...
    -- Nadia Boulanger
      It seems I get the 401 unauthorized as well. So not sure if this is valid solution? Any help here ?
      my $mech = WWW::Mechanize->new; my $username = "user"; my $password = "pass"; my $host="somehost"; my $port="12001" $mech->credentials("$host:$port", "Tomcat Manager Application", "$ +username", "$password"); $mech->get("$url/manager/list"); print Dumper $mech->response; # print $mech->content();