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:
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.)DBSERVER0 = \\PLYSDEV03\DEV03- DBSERVER1 =
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:
Thanks in advance for your help!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:
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: My ping should fail but does not
by Zaxo (Archbishop) on Jun 02, 2004 at 19:02 UTC | |
by mike at rcn (Initiate) on Jun 02, 2004 at 19:56 UTC | |
by Zaxo (Archbishop) on Jun 02, 2004 at 20:39 UTC | |
by mike at rcn (Initiate) on Jun 04, 2004 at 14:29 UTC | |
Re: My ping should fail but does not
by robartes (Priest) on Jun 02, 2004 at 20:28 UTC |
Back to
Seekers of Perl Wisdom