Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: batch ping problem

by Henri Icarus (Beadle)
on Jun 13, 2001 at 19:27 UTC ( #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? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2023-02-08 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?