Ok, I tested your script with google and it works.

Then it maybe related with tomcat auth issue:
I changed your script to work with my tomcat manager:

use strict; use HTTP::Cookies; use LWP::UserAgent; # try to simulate wget: my $cookie_jar = HTTP::Cookies->new( file => "mycookie-tomcat.cookie", autosave => 1, ); my $ua = LWP::UserAgent->new; $ua->credentials ("host:8080","Tomcat Manager Application","user","pas +sword"); $ua->timeout(2); $ua->cookie_jar($cookie_jar); #$ua->env_proxy; if( !@ARGV) { warn "Requesting page"; my $request= HTTP::Request->new (GET=> "http://host:8080/manager/statu +s?XML=true"); my $status=$ua->request ($request); if ($status->is_success) { print $status->decoded_content(); } else { print STDERR $status->status_line, "\n"; return 1; } }; use Data::Dumper; warn "Cookies in jar:"; $cookie_jar->scan(sub { warn Dumper \@_ });
And then it printout cookie when I launch without parameters:
... $VAR1 = [ 0, 'JSESSIONID', '1F627DA1EED0B70CC94F4D3EB9ECD378.host', '/manager', 'host.local', undef, 1, undef, undef, 1, {} ]; ...

but file of cookie is empty:

$ cat mycookie-tomcat.cookie #LWP-Cookies-1.0

I discover in tcpdump / wireshark, tomcat is returning first an 401 error with "You are not authorized to view this page. If you have not changed ...", setting a cookie wich is used by lwp after (it try again the access and the page is loaded correctly), but seems like not saved in the file

Thank you !
PD: What is wrong with my question, so I'm getting negative reputation ?

In reply to Re^4: Simulating --keep-session-cookies wget option with LWP ? by i5513
in thread Simulating --keep-session-cookies wget option with LWP ? by i5513

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.