Skip to content

Instantly share code, notes, and snippets.

@kenzo0107
Last active March 23, 2016 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenzo0107/126e687ebc0a4b1747c7 to your computer and use it in GitHub Desktop.
Save kenzo0107/126e687ebc0a4b1747c7 to your computer and use it in GitHub Desktop.
#!/bin/sh
# IP から HOST 情報取得
# IP一覧
IP_LIST_TXT=ip_list.txt
# 94.23.2.218
# 81.143.127.209
# 188.121.41.145
# 結果出力
RES=result_ip2hostinfo.txt
cp /dev/null ${RES}
while read IP
do
COUNTRY_CODE=$(curl -s curl -s ipinfo.io/${IP}/country)
CITY=$(curl -s curl -s ipinfo.io/${IP}/city)
ORG=$(curl -s curl -s ipinfo.io/${IP}/org)
HOSTNAME=$(curl -s curl -s ipinfo.io/${IP}/hostname)
echo "${IP}\t${COUNTRY_CODE}\t${CITY}\t${ORG}\t${HOSTNAME}" >> ${RES}
done < ${IP_LIST_TXT}
echo "FINISH !"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment