property stored_IP : missing value
display dialog "This script will run as a stay-open application that checks for the current IP address of this computer every 30 minutes and will send the IP address in an email to a specified user if the IP address has changed." buttons {"Quit", "Edit Settings", "Continue"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Quit" then
tell me to quit
else if the button_pressed is "Edit Settings" then
set the localized_file to path to resource "Localizable.strings"
tell application "TextEdit"
activate
open the localized_file
end tell
tell me to quit
end if
on idle
try
set message_subject to localized string "message_subject"
set recipient_name to localized string "recipient_name"
set recipient_address to localized string "recipient_address"
set the HTML_result to do shell script "curl 'http://checkip.dyndns.org'"
set x to the offset of ": " in the HTML_result
set the the HTML_result to text from (x + 2) to -1 of the HTML_result
set x to the offset of return in the HTML_result
set the the IP_address to text 1 thru (x - 2) of the HTML_result
if the stored_IP is not the IP_address then
set the stored_IP to the IP_address
tell application "Mail"
activate
set this_message to make new outgoing message with properties {subject:message_subject}
tell this_message
make new to recipient at beginning of to recipients with properties {name:recipient_name, address:recipient_address}
set content to the IP_address
set visible of this_message to true
end tell
send this_message
end tell
end if
end try
return 1800
end idle
PS : How can I edit that it will send mail it to me every 3 hour period. It does not work. I cannot make it work for me.
Hi,
this works on my machine
.
on idle
try
set message_subject to localized string "message_subject"
set recipient_name to localized string "recipient_name"
set recipient_address to localized string "recipient_address"
set IP_address to do shell script "/usr/bin/curl http://checkip.dyndns.org | /usr/bin/awk '/: / {print $6}' | /usr/bin/cut -f 1 -d '<' "
if the stored_IP is not the IP_address then
set the stored_IP to the IP_address
tell application "Mail"
activate
set this_message to make new outgoing message with properties {visible:true, subject:message_subject, content:IP_address}
tell this_message
make new to recipient at beginning of to recipients with properties {name:recipient_name, address:recipient_address}
send
end tell
end tell
end if
end try
return 1800
end idle
Thank You StefanK ,
It is not work on my mashine.
Is there someone who can edit this from begining to the end totally.
the return value is the time interval in seconds.
If you want 3 hours
return 10800
or
return 3 * hours