l2ping: Keep pinging even if the host is down

Viewed 443

I'm using l2ping to ping constantly a bluetooth device. It works fine until the device is disconnected, when i get a message saying the host is down, and the process ends. I would like the process not to end and keep pinging the device even if it's down, so when it goes up again i get a response.

In other words, I would like to get the same result that I get using ping with the option -t in Windows. Would it be possible with l2ping?

1 Answers

l2ping always exits 1 on any error and it doesn't have a feature like -t on Windows ping.
You can however wrap the command to restart it even if it fails.

l2pingt() { until l2ping "$@"; do :; done; }

This wrapper will restart l2ping every time it exits with an error or until you press Ctrl+C.
You can use it in your terminal or put it in .bash_aliases.

Related