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


Click here to return to the 'An AppleScript to obtain the WAN IP address' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to obtain the WAN IP address
Authored by: jcjamesx on Dec 14, '04 04:49:48PM

I was wondering if anybody could help me make one modification to this script.

I need for it to run on my webserver so that while I am back at home for Christmas, if the IP address changes, I will find out about it and can make the changes I need.

So basically, I need this exact script execpt I would like it to send the email by default, or maybe after it times out at the very begining, if it would just send the email after timing out.

Any help would be great as I am not very good with Applescript.
Thanks!



[ Reply to This | # ]
An AppleScript to obtain the WAN IP address
Authored by: omnimac on Dec 25, '04 07:45:49PM

Hello, I just deleted a few lines. I'm sure there is a better way but this works for me. Also, I set the IP address to be the subject of the email as well as the text in the body.
Cheers! - JP

set response to do shell script "/usr/bin/curl http://checkip.dyndns.org/"
set ip_address to extract_ip(response)
set mailto_addr to "YourEmailAddress"
send_ipget_mail_message(mailto_addr, ip_address)

on send_ipget_mail_message(email_address, ip_address)
tell application "Mail"
activate
set composedMessage to (a reference to (make new outgoing message
at the beginning of outgoing messages))
tell composedMessage
make new to recipient at beginning of to recipients
with properties {address:email_address}
set the subject to ip_address
set the content to ip_address
end tell
send composedMessage
end tell
end send_ipget_mail_message

-- Function to extract ip from HTML returned by dydns.com
on extract_ip(this_text)
set clean_ip to ""
set this_char to ""
repeat with this_char in this_text
set this_char to the contents of this_char
if the this_char is in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."} then
set the clean_ip to the clean_ip & this_char as string
end if
end repeat
return the clean_ip
end extract_ip



[ Reply to This | # ]