Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.)

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!

In reply to My ping should fail but does not by mike at rcn

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-12-01 06:07 GMT
Find Nodes?
    Voting Booth?