Created
April 4, 2012 10:52
-
-
Save rasoliveira/2300342 to your computer and use it in GitHub Desktop.
Prints you external IP address on the screen
This file contains hidden or 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/bash | |
# Filename: myip.sh | |
# Synopsis: Access whatsmyip.com servers and prints you external IP address | |
# on the screen | |
# Author: Rafael Oliveira <[email protected]> | |
# License: Fell free to use, copy, modify, distribute, etc | |
# Note: Do a favor to the whatsmyip.com guys and do not over use | |
# their network. Try to wait 300 seconds to use this program a second | |
# time. If you are having consistent errors running this program, | |
# check http://www.whatismyip.com/faq/automation.asp and try to change | |
# the address below with a new one | |
MYIP_AUTOMATION_URL="http://automation.whatismyip.com/n09230945.asp" | |
# Getting file with your IP address | |
RESPONSE=`wget --quiet -O - ${MYIP_AUTOMATION_URL}` | |
# Checking if the file was correctly downloaded | |
if [ $? -eq 0 ]; then # correctly downloaded | |
echo ${RESPONSE} | |
else | |
echo "Error detecting your IP address. Try again later." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment