is it just me, or does it seem like Apple doesn't want users to create and run our background processes (daemons)?
On occasion, my ISP changes my public IP address. Since I have need to access my home system when traveling, I need to be notified if the public IP address changes. So, I wrote an AppleScript (redacting personal info):
property savedIP : "10.10.10.1"
-- the property value persists UNTIL THE SCRIPT IS RECOMPILED
set theIP to do shell script "curl -s https://ifconfig.me"
if theIP is not equal to savedIP then
-- display dialog "A new IP address has been detected: " & theIP
set theRecipient to "<redacted>"
set theAddress to "<redacted>"
set theSubject to "IP Address Change"
set theTextBody to "Public IP address has changed to " & theIP
set theSender to "<redacted>"
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:theTextBody, visible:true, sender:theSender}
tell theMessage
make new to recipient with properties {name:theRecipient, address:theAddress}
send
end tell
end tell
end if
set savedIP to theIP
I can run this from terminal as 'osacript /Users/<redacted>/IP_ADDRESS_CHANGE_NOTIFICATION.scpt'
So, I turned to Automator, which USED TO HAVE a scheduler capability. But that's no longer present in
Version 2.10 (523). So, I turned to launchd (via launchctl). I can't seem to get anything to load/run with throwing an error. Since cron still exists, I've tried using it instead. I have some success, but as you can see from the code above, the property is supposed to persist until the script is recompiled, yet the set savedIP to theIP does not seem to persist. Is AppleScript broken?
And Shortcuts doesn't have a automation capability, either. What's one to do?