Skip to content

Instantly share code, notes, and snippets.

@rasoliveira
Created April 4, 2012 10:52
Show Gist options
  • Save rasoliveira/2300342 to your computer and use it in GitHub Desktop.
Save rasoliveira/2300342 to your computer and use it in GitHub Desktop.
Prints you external IP address on the screen
#!/bin/bash
# Filename: myip.sh
# Synopsis: Access whatsmyip.com servers and prints you external IP address
# on the screen
# Author: Rafael Oliveira <ludug3r0@gmail.com>
# 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