Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: batch ping problem

by Henri Icarus (Beadle)
on Jun 13, 2001 at 19:27 UTC ( [id://88089]=note: print w/replies, xml ) Need Help??


in reply to batch ping problem

Derek,

There are a number of errors in your code. For one, you are opening PINGIN inside the loop but only closing it outside the loop. Also your regular expression search when looking throught the log is missing a * so it will never match (it should be "([0-9.]*)" )

Finally I think you've got the case wrong, because ping returns the 64 bytes line when machines are available!

All that aside, there's a much easier way to do what you're trying to do, just use the backtick operator, like this:

$ip = "10.32.$octet3.$x"; @data = `ping $ip -w 5`;
That will load the results of the command into an array which you can then process with a single grep command:
print "$ip is not available" if !grep(/^64 bytes from/,@data);

Enjoy!

-I went outside... and then I came back in!!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://88089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-20 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found