Change the while loop
while ( !$username || !$password )
to
until ( $username and $password )
Now try this:
#!/usr/bin/perl use strict qw/refs/; use warnings FATAL => 'all'; use HTTP::Cookies; use LWP::UserAgent; use HTTP::Request::Common qw/POST GET/; my $username = 'Login'; my $password = 'pass'; until ( $username and $password ) { print "\nAkamai Administrator credentials\n", "$username\n", "$password \n"; chomp( $username, $password ); } my $ua = LWP::UserAgent->new( cookie_jar => HTTP::Cookies->new, requests_redirectable => [], timeout => 10, agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0" ); my $target; my $req = GET 'https://control.akamai.com/EdgeAuth/login.jsp'; if ( $ua->request($req)->as_string =~ m["TARGET_URL" value="(.*)" />\n +] ) { $target = $1; } else { print "Can't proceed without: TARGET_URL\n"; exit; } $req = POST 'https://control.akamai.com/EdgeAuth/userLogin', [ login => "Log In", TARGET_URL => $target, username => $username, password => $password ]; $req = GET 'https://control.akamai.com/home/view/main'; print $ua->request($req)->as_string;

In reply to Re: LWP::UserAgent Trying to automate session authentication by Khen1950fx
in thread LWP::UserAgent Trying to automate session authentication by mhearse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.