I’m a AS newbie so bear with me. Here’s my scenario:
My hi-speed ISP at home keeps changing my (dynamic) IP address almost every day.
While I’m on the road, I need to log into a database on my home Mac.
Problem is, I need to know the current IP address of my home Mac in order to log in. I’d like to write a script that will enable me to:
Send an e-mail from the road to the home Mac with the subject “send_ip_address”
Set up a Mail.app rule on the home Mac to run a script, replying to this message with the current IP address in the body text.
It doesn’t strike me as particularly complicated, but I can’t do it on my own.
You’re right, it isn’t difficult. Here’s a basic script (culled by using the search feature for this BBS), I’m sure you can figure out how to set up the rule:
set ip_external to word -6 of (do shell script "curl http://checkip.dyndns.org")
tell application "Mail"
set the_message to make new outgoing message with properties {subject:"My IP", content:ip_external}
make new to recipient at end of to recipients of the_message with properties {name:"Your Name", address:"you@domain.com"}
set visible of the_message to true
send the_message
end tell
change set ip_external to word -6 to set ip_external to word -7 for 10.7.4 support.
working code.
set ip_external to word -7 of (do shell script "curl http://checkip.dyndns.org")
tell application "Mail"
set the_message to make new outgoing message with properties {subject:"My IP", content:ip_external}
make new to recipient at end of to recipients of the_message with properties {name:"Your Name", address:"you@domain.com"}
set visible of the_message to true
send the_message
end tell