I am trying to build a one-line command to monitor when my Internet connectivity drops.
I'd like it so that if I run
ping www.google.com indefinitely (one ping per second), if the word "timeout" exists in an output line, another command runs, but the
ping command continues to run indefinitely.
I'm running this on OS X, so the other command is
say fail so I can audibly hear that there is a problem if I'm not looking at the terminal window.
If it can't be a one-line command, then a bash script would be fine.
I tried this:
ping www.google.com | grep timeout ; say fail
but that only executes the
say command after the user manually terminates the
Then I tried this:
if ping www.google.com | grep timeout ; then say fail ; fi
But that never executes the