Hi Dennis,

Glad to hear the script is of use!
It's been working pretty reliably for me here, although I think there is a small error somewhere because it doesn't always re-try the fetch for some reason. This happens so infrequently I haven't really looked into it, so if you spot any mistakes please let me know.
In case anyone is using this script on a Mac, here's how to set the script to run automatically:
1. Save the script above to ~/Library/Scripts/calibre_fetch.sh, having changed the values highlighted in red.
2. Set the correct permissions with
Code:
chmod 700 ~/Library/Scripts/calibre_fetch.sh
Now you have a generic fetch script. Next, create a set of XML launchd schedules. These live in ~/Library/LaunchAgents.
The following example will fetch Dilbert each day for user "Paul":
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<false/>
<key>Label</key>
<string>com.calibre.dilbert</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/Paul/Library/Scripts/calibre_fetch.sh</string>
<string>dilbert</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>7</integer>
<key>Minute</key>
<integer>10</integer>
</dict>
</dict>
</plist>
Save the file to ~/Library/LaunchAgents/com.calibre.dilbert.plist
The above example should give you the basic idea (you will need to adjust the "/Users/Paul/" absolute path and change the "dilbert" references to the recipe you want). Unfortunately the launchd plist syntax is fairly arcane and seems to vary with each release of Mac OS. The above is designed to work with Tiger (10.4.x). You might want to use
Lingon to create these files, or read the
launchd plist documentation.
Once you've created the launch agent, put it to work:
1. Set the correct permissions on ~/Library/LaunchAgents with
Code:
chmod 700 ~/Library/LaunchAgents
2. Load the launch agent with
Code:
launchctl load ~/Library/LaunchAgents/com.calibre.dilbert.plist
That's it! Mac OS will re-load the launch agent if the machine is rebooted, so from here on it should all 'just work'. You can watch the output from the script in the Mac OS Console if things don't happen as expected.
If you want to kick-start the script (to check it all works), then do so with
Code:
launchctl start com.calibre.dilbert
You can add as many launch agents as you want to ~/Library/LaunchAgents.
Have fun!