Andy Jarrett // Code. Develop. Manage.

Terminal script to sound alarm when an IP address is reachable again

Two scripts to warn you when either an address is UP or DOWN.

Alarm when address is reachable (good if the box or your internet connection is down):

pingAddress=google.com
while :
do
  ping -t 2 -o pingAddress && say ping $pingAddress working
  sleep 2
done
      

This script sounds an alarm when it does not connect to an address:

pingIpAddress=google.com
 while :
 do
   ping -t 2 -o -c 1 $pingIpAddress || say ping to $pingIpAddress failing
   sleep 2
 done
    
I’m here, learning and working away. If you liked this content and want to keep me going, consider buying me a coffee.
Your support keeps this site running and the coffee brewing! ☕️