Hi, I am trying to write a perl script which passes through our firewall. We have a system at work which requires a separate user name/ password which is needed to access the global internet and if you do not make an HTTP request for a certain period of time, then you have to re-login. Now, ordinarily, this is not a problem since I just run one of those news alert programs which checks for news every 5 minutes and so it's not a huge bother. However, I have a few processes that I run with "at" (Win NT 4.0) on the weekend, and I would like to ensure that these run by running this script first.

I've Googled and SuperSearched and still no luck. What I have so far (pretty much copied from the perl cookbook & the LWP docs) is the following:

use strict; use diagnostics; use LWP::UserAgent; use HTTP::Request; use HTTP::Response; my $ua = LWP::UserAgent->new(); $ua->agent("Test/0.01"); $ua->credentials('mysite', 'myrealm', 'myuserid','mypassword'); my $req = HTTP::Request->new('GET', 'http://www.yahoo.com'); my $response = $ua->request($req); if ($response->is_error()) { printf " %s\n", $response->status_line; } else { print $response->content(); }

This returns 401 Unauthorized as the status line when my firewall connection is inactive (i.e. more than X minutes have elapsed (and my correct site, realm, username, password are filled in)

Normally, if I try to login through the firewall for the first time by typing in an external URL, it prompts me with the familiar dialog box (Site/Realm/Username/password). If I hit cancel, it redirects me to http://{IP address of firewall machine}/fwauthredirect{ip address of web server}id{a numeric code, looks to be a sequence number}

Thanks for any insight you can provide. If I left out any info you need, let me know.


In reply to Trying to pass through firewall programmatically by dze27

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.