Jun 29, 2009

Perl check web page alive status

use LWP::UserAgent;
use HTTP::Headers;
use Net::SMTP;
my $ip= $ARGV[0];
my $url=$ARGV[1];
my $agent_name='myagent';
my $ua=LWP::UserAgent->new($agent_name);

my $request=HTTP::Request->new(GET=>$url);

$request->header(Accept=>'text/html');

my $response=$ua->request($request);
if (!($response->code( )==200 || $response->code( )==401))
{
write_mail();
}