Advertisement
uriel1998

Am I Online?

Nov 25th, 2011
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.45 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # simple wrapper to test and see if you're online so your scripts don't waste your time (or clog your log).
  4. # I test this way because of hotspots that let you *connect* - but you aren't online.
  5.  
  6. cmd="$@"
  7.  
  8. ext_ip=$(/usr/bin/wget -q -O - checkip.dyndns.org | /bin/sed -e 's/[^[:digit:]|.]//g')
  9. len_ext_ip=${#ext_ip}
  10. if [ $len_ext_ip -lt 16 ]; then
  11.     if [ $len_ext_ip -gt 7 ]; then
  12.     exec $cmd
  13.     fi
  14. fi
  15. #echo "$cmd"
  16. #echo "$ext_ip"
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement