💾 Archived View for gemini.mingmengtou.org › 2021-04-26-myipcc-script.gmi captured on 2023-12-28 at 15:25:07. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

neil in gemini space

myipcc script - 2021-04-26

a short script to get our ip and the cc of that ip according to whois.

2021-04-26 - wikipedia article about whois.

#!/bin/bash
#
# get ip and country of ip and echo these to stdout
#  may output more than one country depending on whois response.
# 
# n c timms 2021-04-26
#
# var
# getmyipurl is what we give to curl to go get our ip
#  change this to use the service of your choice
# 
getmyipurl="https://mingmengtou.org/cgi-bin/myip.sh"
#
# put ip in var myip
#  curl silent to avoid fetching output
#
myip=$(curl -s $getmyipurl)
#
# put country in var
#  whois provides information about myip
#  grep extracts country info from whois repsponse then
#  awk prints col 2 of the country info: just the country code.
#
country=$(whois $myip | grep country | awk '{ print $2 }')
#
# echo results
echo $myip $country
exit 0

---

return to gemini.mingmengtou.org index page.

---

neil.gemini@mingmengtou.org

content licensed CC-BY-SA 4.0 unless stated.

creative commons licence information.