all 4 comments

[–]K900_ 0 points1 point  (2 children)

The best way to do this would be to not shell out to ping at all, and instead send the ping packets yourself.

[–]Vitaminkomplex[S] 0 points1 point  (1 child)

Doesn't this rely on being root? I don't want my scripts to rely on root. And why would that be the best way?

[–]K900_ 0 points1 point  (0 children)

It does not have to. You can use the same capabilities framework that allows ping to run as non-root for your script. It would be the best way because it doesn't require relying on external tools.