in reply to Re^8: WWW::Mechanize Problem
in thread WWW::Mechanize Problem

Hi ikegami (Cardinal) and all Monks,

.oO( I'd rather be a Chickadee )

From the docs for credentials

The $netloc is a string of the form "<host>:<port>".

Instead of
$ua->credentials('goweb.corp.global.level3.com/sites/ti_nm/tni/default +.aspx:80', ...);
you should be using
$ua->credentials('goweb.corp.global.level3.com:80', ...);

That sets the user/passwd for all requests to that server, including http://goweb.corp.global.level3.com/sites/ti_nm/tni/default.aspx.

Replies are listed 'Best First'.
Re^10: WWW::Mechanize Problem
by Anonymous Monk on Apr 08, 2009 at 18:52 UTC
    Hello Cardinal,:)

    I really apologize for disturbing you a lot over a single topic but i joined this community to learn a lot of perl. Please bear with me.
    I changed my code as you suggested and guess what, i am getting 500 Internal server error
    #!C:/perl/bin/perl.exe use LWP::UserAgent; use HTTP::Request::Common; my $url= 'http://punsez138451d/L3NOCALM/default.aspx'; my $ua = new LWP::UserAgent(keep_alive => 1); $ua->credentials('punsez138451d:80','',"INFLEVEL3\\Venkatesan_G02",'pa +ssword'); $request = GET $url; print "--Performing request now...------------------\n"; $response = $ua->request($request); print "--Done with request---------------------------\n"; if ($response -> is_success) { print "It worked!->". $response->code. "\n"; } else { print "It didn't work!->". $response->code. "\n"; } $contents = $response -> content(); #print "$contents\n"; open(FH,">C:/eonet.html"); print FH $contents; close FH; print $response->status_line(), "\n"; print $response->headers()->as_string();
    Result:
    C:\Documents and Settings\venkatesan_G02\Desktop>perl automate.pl --Performing request now...------------------ --Done with request--------------------------- It didn't work!->500 500 Internal Server Error Connection: close Date: Wed, 08 Apr 2009 18:55:22 GMT Server: Microsoft-IIS/6.0 Content-Length: 100 Content-Type: text/html Client-Date: Wed, 08 Apr 2009 18:55:23 GMT Client-Peer: 4.33.38.79:80 Client-Response-Num: 2 MicrosoftSharePointTeamServices: 12.0.0.4518 Title: Error X-Powered-By: ASP.NET
    Please advice
      Sounds like a problem with the .aspx script (not an auth/autz problem). Check the server's logs.
        Will do Sir. Thanks a lot!!!
      An appendix to the above reply,
      When i tried changing the credential line to the one shown below
      $ua->credentials('punsez138451d/L3NOCALM:80','',"INFLEVEL3\\venkatesan +_g02",'password');

      I am getting the following error
      C:\Documents and Settings\venkatesan_G02\Desktop>perl automate.pl --Performing request now...------------------ --Done with request--------------------------- It didn't work!->401 401 Unauthorized Date: Wed, 08 Apr 2009 19:02:07 GMT Server: Microsoft-IIS/6.0 WWW-Authenticate: Negotiate WWW-Authenticate: NTLM Content-Length: 1656 Content-Type: text/html Content-Type: text/html; charset=Windows-1252 Client-Date: Wed, 08 Apr 2009 19:02:08 GMT Client-Peer: 4.33.38.79:80 Client-Response-Num: 1 Client-Warning: Unsupported authentication scheme 'negotiate' MicrosoftSharePointTeamServices: 12.0.0.4518 Title: You are not authorized to view this page X-Powered-By: ASP.NET

      Thanks in advance
        punsez138451d/L3NOCALM is not a host name. The authentication was working in the previous post.
        http://punsez138451d/L3NOCALM/default.aspx'
        is short for
        http://punsez138451d:80/L3NOCALM/default.aspx'
        where
        • "http" is the scheme.
        • "punsez138451d" is the host name.
        • "80" is the host port.
        • "/default.aspx" is the path.

        The credentials are for the entire host, specified using it's name and it's port.