#!/usr/bin/perl use warnings; use strict; use LWP::Debug qw( + ); use WWW::Mechanize; use CGI; use MIME::Base64; use HTTP::Cookies; my $netloc = "10.4.4.4:8080"; my $url = "http://" . $netloc . "/admin"; my $realm = "Realm"; my $username = "user"; my $password = "pass"; my $cookie_jar = HTTP::Cookies->new( file => 'cookies.dat', autosave => 1, ); my $agent = WWW::Mechanize->new( autocheck => 1, quiet => 0, agent_alias => 'Mac Mozilla', cookie_jar => $cookie_jar, ); # Supply the necessary credentials $agent->credentials($netloc, $realm, $username, $password); $agent->get($url); # Throw error if page not found $agent->success() or die "Can't fetch the Requested page";