http://www.perlmonks.org?node_id=359651

mike at rcn has asked for the wisdom of the Perl Monks concerning the following question:

Hi All:

A newbie to Perl, I have been wrestling with Ping for a couple of days now, and have completely run out of ideas.

In part of a process, I am pre-checking to ensure the remote servers are available, before modifying files and sending them to those servers.

My unit test includes the following rows in my ini file:

DBSERVER0 = \\PLYSDEV03\DEV03- DBSERVER1 =
My code strips the DBSERVERn value down to just the servername and pings it. (The second one intentionally has a blank value and should, therefore, fail the ping.)

BUT . . . both pings pass the test!

Following is the relevant code within the loop through the DBSERVERn keys in the ini section.I'm using use Net::Ping;

printf "$_: $dbSrvrUNC\n"; my $dbSrvrBox = $dbSrvrUNC; $dbSrvrBox =~ s/^(\\\\)//; # Get rid of any leading "\" + for UNC if ($dbSrvrBox =~ /\w+/) {$dbSrvrBox = $&}; # Save only the box name printf "DB Server to be tested for accessibility: $dbSrvrBox\n\n"; # Ensure the connection to the DB Server is available if (pingecho($dbSrvrBox, $timeout)) { &msgLog ("DB Server ($dbSrvrBox) is accessible at startup.\n"); printf "\n$dbSrvrBox is accessible at startup.\n\n"; } else { &msgLog ("Cannot access $dbSrvrBox - abending.\n\n"); &stdErr ("Cannot access $dbSrvrBox - abending.\n\n"); &abend ("Cannot access $dbSrvrBox "); };
##############################

Following is the related output:

DBSERVER0: \\PLYSDEV03\DEV03- DB Server to be tested for accessibility: PLYSDEV03 PLYSDEV03 is accessible at startup. DBSERVER1: DB Server to be tested for accessibility: is accessible at startup. Processing to be performed for:
Thanks in advance for your help!