Guest User

Untitled

a guest
Jun 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/bin/sh
  2. # on macOS
  3. # brew install terminal-notifier
  4. while true
  5. do
  6. ping -c 1 www.baidu.com 1>/dev/null 2>&1
  7. if [ $? -eq 0 ];then
  8. #echo 'Network is up'
  9. #notify-send -t 1000 'Network' 'Network is up!'
  10. # on macOS
  11. #terminal-notifier -title 'Network' -message 'Network is up!'
  12. :
  13. else
  14. DATE=`date`
  15. echo $DATE' Network is down...Try reconnecting'
  16. #notify-send -t 1000 'Network' 'Network is down!'
  17. # on macOS
  18. terminal-notifier -title 'Network' -message 'Network is down!'
  19. # path to another script about logging into the web.
  20. ~/Desktop/Surf.sh
  21. sleep 2
  22. ping -c 1 www.baidu.com 1>/dev/null 2>&1
  23. if [ $? -eq 0 ];then
  24. echo 'Reconnected.'
  25. else
  26. echo 'failed, retry ping next round. If this keeps showing, then network is totally down.'
  27. fi
  28. fi
  29. # loop every 60s
  30. sleep 60
  31. done
Add Comment
Please, Sign In to add comment