-- Leo's gemini proxy

-- Connecting to gemini.mingmengtou.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-GB

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.

-- Response ended

-- Page fetched on Thu May 2 10:12:39 2024