Blip Sid wrote: > Hello, > > I would like to write a small script to login to an > external website (outside of company firewall). The > purpose is to ensure that connectivity is active to > this external web site for system monitoring purpose. > > My question is what modules are best suited for this. > I am planning on using lwp. Are there others that are > better suited? If the website requires a login with > userid and pw, can this be accomadated as part of the > script. > > My hope is that one of the module allows me to request > a connection, and if not successful will print out a > "die" statement. > > I am looking for any bits of codes and tips to > accomplish. Thanks again for the help.
use strict; use LWP; use LWP::UserAgent; use Data::Dumper; $Data::Dumper::Indent=1; my $url = "http://localhost/"; my $ua = LWP::UserAgent->new or die "new UserAgent: $!"; #$ua->agent('Mozilla/4.0'); # fake Netscape client if necessary my $req = new HTTP::Request 'HEAD', $url or die "new Request: $!"; my $res = $ua->request($req) or die "request: $!"; if ($res->is_success) { print Data::Dumper->Dump([$res], [qw(response)]) if $debug; print "HEAD request to $url OK\n"; } else { print "Error on HEAD request to $url\n"; } __END__ -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
