Daylite
Daylite

Reputation: 509

Ping status and return

I am writing a perl script which issues a ping to a certain IP address, with a ping size of 65000 and count of 1000.

Now when the remote PC is up, things are okay. The ping succeeds and ends after sending 1000 pkts.

However, in case of failure, it always returns "Destination host unreachable". Ping keeps on trying for too long trying to send arp requests/ping requests before it eventually gives up with a 100% pkt loss string.

My question is, how can I make ping to exit if lets say the initial 100 pings itself do not generate a response. I do not want to wait for too long in case initial pings itself fail. I want ping to exit. How do I do this?

I am currently using Linux for my script. Please let me know how to do this for

[Please note the size of the ping pkt can vary. So I want a solution which is independent of the size/count]

Upvotes: 0

Views: 693

Answers (1)

krisku
krisku

Reputation: 3993

I would recommend using the Net::Ping module which gives you the flexibility to control individual pings directly from your script.

Upvotes: 1

Related Questions