[BNE-PM] This one bounced.
Gordon Fletcher
G.Fletcher at mailbox.gu.edu.au
Sun Aug 8 11:00:54 CDT 1999
Date: Fri, 06 Aug 1999 16:53:57 +1000
From: Ramon Buckland <r.buckland at qut.edu.au>
That's interesting .. as we are actulally testing for the ftp server to
be up
here is what I modified it to
############################################################
sub ping_test {
my $host = shift;
my $command = "ping -c 2 " . $host;
return (`$command` =~ /2 packets received/);
# PING 131.181.22.1 (131.181.22.1): 56 data bytes
#
# --- 131.181.22.1 ping statistics ---
# 2 packets transmitted, 2 packets received, 0% packet loss
}
############################################################
But yeah .. that doesn't guarantee the ftp server is up though.
- and code portability - NIL
At 04:17 6/08/99 +1000, you wrote:
>If you are trying to see if a web or ftp server is up you could do some
>thing like this...
>
>#!/usr/bin/perl
>use IO::Socket;
>
>$host = $ARGV[0] || "localhost";
>
>#is there a webserver on $host??
>my ($newsock) = new IO::Socket::INET(
> PeerAddr => "$host",
> PeerPort => "80",
> Proto => "tcp",
> );
>
>if($newsock)
>{
> shutdown $newsock, 2;
> print "$host is alive.\n";
>}else
>{
> print "$host is dead.\n";
>}
>
>0;
Ramon Buckland, IT Systems Administrator, Ph: 07 3864 1289 Fx: 07 3864 1823
Queensland University of Technology, Facilities Support Services
Email: r.buckland at qut.edu.au http: www.fss.qut.edu.au
"If you don't want problems, don't use computers" - author unkown
More information about the Brisbane-pm
mailing list