Last active
November 2, 2018 13:16
-
-
Save acodega/489cd7e1a295bc2abce8cd3c60e2624c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
myIP=`curl -L -s --max-time 10 http://checkip.dyndns.org | egrep -o -m 1 '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'` | |
myLocationInfo=`curl -L -s --max-time 10 http://freegeoip.net/xml/$myIP` | |
myCountryCode=`echo $myLocationInfo|egrep -o '<CountryCode>.*</CountryCode>'| sed -e 's/^.*<CountryCode/<CountryCode/' | cut -f2 -d'>'| cut -f1 -d'<'` | |
myCity=`echo $myLocationInfo|egrep -o '<City>.*</City>'| sed -e 's/^.*<City/<City/' | cut -f2 -d'>'| cut -f1 -d'<'` | |
myRegionName=`echo $myLocationInfo|egrep -o '<RegionName>.*</RegionName>'| sed -e 's/^.*<RegionName/<RegionName/' | cut -f2 -d'>'| cut -f1 -d'<'` | |
echo "<result>$myCity, $myRegionName - $myCountryCode</result>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment