I always wrap the ping in an eval statement, which tells me whether it's the module or
the result
of the ping that has problems, like this:
eval{ $Ping = Net::Ping->new( 'icmp' )};
if( $@ eq '' ) {
$IP_Address = inet_aton( $Host );
$IP_Address = defined $IP_Address ? ' (' . inet_ntoa( $IP_Address ) . ')' : '';
$PingOK = $Ping->ping( $Host );
defined $PingOK || die "Workstation not reachable";
$PingOK || die "Workstation not responding";
} else {
die $@;
} # End if
In this case, I use Net::Ping to see if the IP protocol is loaded (some of my clients
use dial-up
to a DHCP server, and still use only NetBEUI on the local LAN).
If it is loaded, I then get the IP Address from the HostName entered earlier in the
script. I then
check to see if the result of Ping is undef or 0, and print out any errors.
Hope this helps,
--Chuck
--- Michael Stidham <[EMAIL PROTECTED]> wrote:
> Louis,
> I use something like this in all of my scripts...
> use Net::Ping;
> my $host = Net::Ping->new("icmp");
>
> while (<MACH>) {
> chomp ($client = $_);
> $client =~ tr/a-z/A-Z/;
> if ($host->ping($client, 5)){&determine}
> else {print UNREACHABLE ("$client was unavailable for communication\.\n:
> $!")}
> }
> Hope this tid bit helps...
>
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin