I have a long script on a machine and if the script runs after waking the machine, it will go back to sleep before the script is finished.
I do not want to set the sleep timer to longer.
I am not sure if I go about it in the right way, but I thought of setting the Energy Saver to longer before the script and back to short at the end. Problem is it wants a password and so cannot run unattended.
Is there a way of storing the password in the Keychain?
Here is the script:
do shell script "pmset sleep 0" with administrator privileges
-- long and slow script
do shell script "pmset sleep 14" with administrator privileges
Caffeine is now scriptable, which may be a better solution than changing preference or touching files. It can be set to not allow sleeping when starting the script, and then set to allow sleeping when the script finishes. That way if you want to change your sleep settings overall you only have to change the preferences, not the script(s).