Send an email when external IP address changes ...

Hi,

Can someone help me create a idler script to send me an email whenever my external IP address changes ? How can I do that ?

Robert Lespérance
Québec, Canada

Hi rlesperance,

I don’t have an answer, but what is the difference between an ip address and an external ip address?

Thanks,
kel

He means his internet ip (aso called public ip).

«External» refers to my web IP address not my local (LAN) IP address. With this address I can communicate with my house/office LAN network.

The script works … but not inside the idler. Here is my idler:

-- Idler that checks every hour if the external IP address has changed


property emailRecepient : "Me"
property emailAddress : "myname@mydomain.com
property currentAddress : ""
property newAddress : ""




on idle
	
	-- Read my actual external IP address.
	set newAddress to do shell script "curl http://checkip.dyndns.org | awk '/: / {print $6}' | cut -f 1 -d '<' "
	
	-- If the IP address has been mofidied since last check ...
	if newAddress is not equal to currentAddress then
		
		-- ... send me an email confirmation.
		tell application "Mail"
			set newMessage to make new outgoing message with properties {visible:true, subject:"Nouvelle adresse IP ...", content:"L'adresse IP externe de ImacIntel vient d'être modifiée à : " & newAddress}
			tell newMessage
				make new to recipient at end of to recipients with properties {name:emailRecepient, address:emailAddress}
			end tell
			activate
			send newMessage
		end tell
		
	end if
	
	-- Wait 60 seconds before the next check.
	return 3600
	
end idle

Hi … Could someone save the above script as an app and try to launch it. Here it seems to crash … without opening.

OK … I got it. I forgot that one. The «Do not quit after lauch» option was not checked when I created the app. For whom this handler could be useful:

-- Idler that checks every hour if the external IP address has changed


property newAddress : ""
property currentAddress : ""
property newMessage : ""
property emailRecepient : "Your Name"
property emailAddress : "name@whatever.com" -- the email address the message has to be sent



on idle
	
	-- Read my actual external IP address.
	tell application "System Events" to set newAddress to do shell script "curl http://checkip.dyndns.org | awk '/: / {print $6}' | cut -f 1 -d '<' "
	
	-- If the IP address has been mofidied since last check ...
	if newAddress is not equal to currentAddress then
		
		-- ... send me an email confirmation.
		tell application "Mail"
			set newMessage to make new outgoing message with properties {visible:true, subject:"Nouvelle adresse IP ...", content:"L'adresse IP externe de ImacIntel vient d'être modifiée à : " & newAddress}
			tell newMessage
				make new to recipient at end of to recipients with properties {name:emailRecepient, address:emailAddress}
			end tell
			activate
			send newMessage
		end tell
	end if
	
	-- Define the current IP address to the new IP address
	set currentAddress to newAddress
	
	-- Wait 1 hour before the next check.
	do shell script "/bin/sleep 3600"
	
end idle

Thanks anyway … the answer was found in this forum.

Regards.