in reply to Ping a Server
What have you tried?open the Server List file
read in line by line
for each line/servername ping the server (either OS ping with $result = `ping $_`;then do some regex on the $result or look at Net::Ping)
close Server List file
What does your list of servers look like?
Post some code so we can look and make suggestions.
Update: Assuming you file has a server name on each line try the following..
The code below works for me using Net::Ping PS I havent done the open file and read in a list etc.
#! /usr/bin/perl use strict; use warnings; use Net::Ping; my ($host,$rtt,$ip); my @host_array = ("OSSTNGMCN01", "OSSTNGMCN04", "PROJECTX99"); my $p = Net::Ping->new("syn"); $p->{port_num} = getservbyname("http", "tcp"); foreach $host (@host_array) { $p->ping($host); } while (($host,$rtt,$ip) = $p->ack) { print "HOST: $host [$ip] ACKed in $rtt seconds.\n"; }
-----
Of all the things I've lost in my life, its my mind I miss the most.
Of all the things I've lost in my life, its my mind I miss the most.
In Section
Seekers of Perl Wisdom