2008年6月21日 星期六

check web service

睇下個URL係咪正常去得到.


#!/usr/bin/perl
#
# check web service
#
use strict;
use LWP::Simple;
use URI::URL;

my $url = shift;
if (! ($url) )
{
print "Usage : $0 \n";
exit(-1);
}

# make and check url
my $chkurl = URI::URL->new($url);
my @headers = head($chkurl);
if (@headers)
{
print "Host : $url\n";
print "Server : @{[pop @headers]}\n\n";
}
else
{
print "Unable to retrive @{[$chkurl->as_string]}\n\n";
}

exit(0);

沒有留言: