Script for Email Notification of IP Address Change

Posted on
Wed Oct 28, 2015 8:41 am
ajderderian offline
Posts: 3
Joined: Nov 16, 2009
Location: Orange County CA

Script for Email Notification of IP Address Change

I had an issue where my DynDNS updater did not update a new IP address provided by my ISP. So as a backup I came up with this script that I embedded in a scheduled task that runs every hour. It checks my IP Address and if it is different than the current one , stored in an Indigo variable "IPAddress", I email myself the new address. Then I can manually change the IP Address at DynDNS and all will be good.

I hope this helps someone!
Ara Derderian
HDTV and Home Theater Podcast
http://www.htguys.com

Code: Select all
set recipientName to "YourName"
set recipientAddress to "youraddress@yourmailprovider.com"
set theSubject to "IP Address Changed"
set newIPAddress to word 25 of (do shell script "/usr/bin/curl checkip.dyndns.org")

if the value of variable "IPAddress" is not equal to newIPAddress then
   set the value of variable "IPAddress" to newIPAddress
   tell application "Mail"
      
      ##Create the message
      set theMessage to make new outgoing message with properties {subject:theSubject, content: newIPAddress, visible:true}
      
      ##Set a recipient
      tell theMessage
         make new to recipient with properties {name:recipientName, address:recipientAddress}
         
         ##Send the Message
         send
         
      end tell
   end tell
end if

Posted on
Wed Oct 28, 2015 9:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Script for Email Notification of IP Address Change

Hey Ara, thanks for the contribution!

[MODERATOR NOTE] moved to the User Contributions/AppleScripts forum

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests