Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # on macOS
- # brew install terminal-notifier
- while true
- do
- ping -c 1 www.baidu.com 1>/dev/null 2>&1
- if [ $? -eq 0 ];then
- #echo 'Network is up'
- #notify-send -t 1000 'Network' 'Network is up!'
- # on macOS
- #terminal-notifier -title 'Network' -message 'Network is up!'
- :
- else
- DATE=`date`
- echo $DATE' Network is down...Try reconnecting'
- #notify-send -t 1000 'Network' 'Network is down!'
- # on macOS
- terminal-notifier -title 'Network' -message 'Network is down!'
- # path to another script about logging into the web.
- ~/Desktop/Surf.sh
- sleep 2
- ping -c 1 www.baidu.com 1>/dev/null 2>&1
- if [ $? -eq 0 ];then
- echo 'Reconnected.'
- else
- echo 'failed, retry ping next round. If this keeps showing, then network is totally down.'
- fi
- fi
- # loop every 60s
- sleep 60
- done
Add Comment
Please, Sign In to add comment