Do you have a question? Post it now! No Registration Necessary. Now with pictures!
November 12, 2007, 12:35 pm
rate this thread
see if it is down/unavailable.
The script just reads the page header, and as such doesn't download
I put in a five minute delay via the sleep 600; You might change that
to what ever is more convenient to you.
I am only checking for status codes commencing with a "5", which are
returned when a server is unavailable (routing issues for example),
among other times. Again, you may wish to expand on this.
Under Windows the following script runs until ctrl-break is pressed.
# The url you wish to test
$url = "http://www.example.com ";
$ua = LWP::UserAgent->new;
my $response = $ua->get($url);
$status = $response->status_line;
# printf "%s\n",$response->status_line;
($sec, $min, $hour, $monthday, $month, $year, $weekday, $yearday,
$isdaylight) = gmtime;
$year += 1900;
$month += 1;
# Status codes commencing with a 5 indicate a server problem; 4 a
client problem (including page not found); 2 everything is okay.
if (substr($status,0,1) eq "5")
print " $monthday/$month/$year $hour:$min Server is
print "$monthday/$month/$year $hour:$min Server is okay\n";
This is a quick and efficient system offered as is, don't bother
flaming me, use it if you like, don't if you don't.