Advertisement
uriel1998

Check for IP address at hotspot

Oct 24th, 2011
383
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #Sometimes when I've hooked up to a hotspot, before the "login" I'll get a bunch of crap
  4. #instead of an actual IP address in my conky config.  This fixes that.
  5.  
  6. #check for ip address
  7. ext_ip=$(wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]|.]//g')
  8. #check the length of the returned string.
  9. len_ext_ip=${#ext_ip}
  10.  
  11. if [ $len_ext_ip -gt 16 ]; then
  12.     # more than 16 digits, it's garbage; we're not connected.
  13.     echo "0.0.0.0"
  14. else
  15.     # return the actual ip address.
  16.     echo "$ext_ip"
  17. fi
  18.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement