Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Fix For Lion' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fix For Lion
Authored by: desepticon on Apr 10, '12 12:04:39AM

I'm running Lion and this wasn't working for me so I fixed some things. I changed the script for external ip addresses to use wget, which isn't default on os x. I added growlnotify notification and fixed a commenting issue at the bottom. Also, you should use launchd instead of cron to schedule it.

#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/opt/local/bin/

# Written to email you if your computer has an IP address change. Invoke with a launchd plist.


# MANUALLY EDIT the line two below this one to list all email addresses that should receive notification of results.
# Only edit what is after the equals sign - addresses should be separated by spaces. Be sure to keep the single quotes intact.
tobenotified='xxxxxxxxx@xxxx.com'

echo "Checking current internal and external ip address..."
touch /tmp/myip.txt

echo -e "en0:\n$(ifconfig en0 | grep -oP 'inet \K(\d{1,3}\.){3}\d{1,3}')\n\nen1:\n$(ifconfig en1 | grep -oP 'inet \K(\d{1,3}\.){3}\d{1,3}')" > /tmp/myip_temp.txt
echo >> /tmp/myip_temp.txt
echo "Outside:" >> /tmp/myip_temp.txt
wget http://automation.whatismyip.com/n09230945.asp -O - >> /tmp/myip_temp.txt

if diff /tmp/myip_temp.txt /tmp/myip.txt &> /dev/null; then exit; else
echo "Your ip adress has changed. Notifying you via email now..."
mv /tmp/myip_temp.txt /tmp/myip.txt
growlnotify --image /Users/user/Pictures/icons/xicon.png -i png -p High -s -t MyXProtect -m "Your ip address has changed."
cat /tmp/myip.txt | mail -s "IP Address Change on $(date '+%m/%d/%y @ %H:%M:%S')" $tobenotified -f ipchange@no-reply.com -F "IP CHANGE NOTIFICATION";
fi

############
#One of my colleagues added the following lines above the if-statement
#to track if his external IP address changes as well:
############

#echo >> /tmp/myip_temp.txt
#echo "Outside:" >> /tmp/myip_temp.txt
#curl http://www.whatismyip.com/automation/n09230945.asp >> /tmp/myip_temp.txt

############



[ Reply to This | # ]