|
|
10.4: Retrieve WAN IP via script and Automator
Here's an Applescript I use to report IP address changes via a message sent through Mail.app. I save it as an application and run it regularly using a cron job.
try set currentIP to (do shell script "curl -sS http://whatismyIP.org") on error quit end try try set lastknownIP to (do shell script "cat /Users/Shared/externalIP.txt") on error set lastknownIP to "0.0.0.0" do shell script "echo " & currentIP & " > /Users/Shared/externalIP.txt" end try if currentIP is not lastknownIP then --if the IPs are not the same, then report it set mailSubj to "New IP: " & currentIP tell application "Mail" set theMessage to (make new outgoing message with properties {subject:mailSubj, content:"IP address has changed.", visible:false}) tell theMessage make new to recipient at end of to recipients with properties {name:"to recipient", address:"torecipient@company.com"} make new cc recipient at end of cc recipients with properties {name:"cc recipient", address:"ccrecipient@company.com"} end tell send theMessage end tell do shell script "echo " & currentIP & " > /Users/Shared/externalIP.txt" end if --- |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|