#!/usr/bin/perl use strict; use warnings; use LWP; my $path = "Infrastruktur/Svitsjoversikt"; my $loginurl = "http://intranett.oikt.local/user/login"; my $finaluri = "/Infrastruktur/Svitsjoversikt"; my $user = "foo"; my $pass = "bar"; my $param = "Login=$user&Password=$pass&LoginButton=1&RedirectURI=$finaluri"; # Create a user agent my $ua = LWP::UserAgent->new; $ua->agent("monitorezex/1.0 "); #push @{ $ua->requests_redirectable }, 'POST'; # Make POST requests redirectable $ua->cookie_jar({ file => "cookies.txt" }); # Create a request my $req = HTTP::Request->new( POST => $loginurl ); $req->content_type('application/x-www-form-urlencoded'); $req->content( $param ); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { print "SUCCESS!\n"; print $res->as_string; } else { print "FAILURE: " . $res->status_line . "\n"; print $res->as_string; } exit;