return to first page linux journal archive
keywordscontents

Listing 1. HTTPPing.pl

#!/usr/bin/perl$URL = $ARGV[0];
$debug = $ARGV[1];
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent;
$ua->agent('Monitor/1.0');
$request = new HTTP::Request('HEAD', $URL);
$response = $ua->request($request);
if ($response->is_success) {
   print "$URL is up.\n" 
   if ($debug==1);
      exit(1); 
   }
   else {
      print "$URL is down.\n" 
      if ($debug==1);
      exit(0);
   }