PDA

View Full Version : Scripts and error detection


edoates
06-10-2006, 05:09 PM
I have the following lines in a SuperDuper backup scripts, but when I got an I/O error (a legitimate one, unfortunately), the "onError" condition was not activated. I use the script to automate nightly backups, and create a text file with either a "succeeded" or "failed" line, and use that to alert me to look at the log file. Since the "onError" was not activated, I didn't discover the error for a new days.

The script appears to "quit" normally.

Are all errors supposed to be caught by the "onError" condition? I'm runnint the latest version (2.1.1 V78).

The script segment:

tell application "SuperDuper!"
try
--Wait until SuperDuper! is idle before loading and running the desired session
repeat while status is not idle
--Sleep # seconds is the best way to "wait" without using the CPU
tell application "System Events" to do shell script "sleep 5"
end repeat
if status is idle then
--Specify the saved settings as either an absolute path or just the name
run using settings "Backup Eds Office" without user interaction
end if
--Wait until the session is done
repeat while status is running
--Sleep # seconds is the best way to "wait" without using the CPU
tell application "System Events" to do shell script "sleep 5"
end repeat
on error errMsg
display dialog errMsg & " See section 12 of the User's Guide for help with this script."
set message_text to "echo " & (return) & (current date) &
": Backup Eds Office ERROR." & (return) & " See SUPERDUPER LOG." & (return) & (return) &
" >>/users/edoates/desktop/backup_log.txt"
end try
--Once done, tell SuperDuper! to eject Eds Office Backup and quit
quit

Ed Oates

dnanian
06-10-2006, 06:10 PM
There are two types of error that SD! can generate. The first is a "preflight" error -- that is, before copying starts, during the load of the settings. If you get an error here, it enters the "on error" block.

The second is a post-copy error. To trap that, you must check the status after the run. If it's "done", there were no errors. Otherwise, an error occurred.