dze27 has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Trying to pass through firewall programmatically
by idnopheq (Chaplain) on Sep 10, 2001 at 23:39 UTC | |
by dze27 (Pilgrim) on Sep 11, 2001 at 00:07 UTC | |
Re: Trying to pass through firewall programmatically
by nardo (Friar) on Sep 10, 2001 at 23:39 UTC | |
by idnopheq (Chaplain) on Sep 10, 2001 at 23:59 UTC | |
by dze27 (Pilgrim) on Sep 11, 2001 at 00:17 UTC |