Let's take a look at my backup script, which only has
four commands:
try tell application "Finder" try -- put in it's own try block because it'll error -- out if it can't find volume. We still want some -- file backups to occur. mount volume  "afp://jennifer.tgd-inc.com/jennifer_data" as user name  "Kevin C. Wong" with password "xxxxxx" end try -- open "File Synchronization" control panel. This will -- start file backups. Once done they start again after -- one minute, so we want to give it some time to do -- backups but kill it so it doesn't constantly use -- AppleShare. open file "ATA_00:System Folder:Control Panels:File Synchronization" delay 900 end tell tell application "File Synchronization" quit end tell end try
First of all, it's in a big try...end try block so that if there is an
error
the script will just quit. Basically, if there is an error in a try
block, the
script jumps to the error handling routines right after the try block,
if no
routines exist then the script just continues after the try block. This
is the
same reason why the mount volume command is in its own try block: if
there is
an error, I still want the File Sync to take place so that some files
are
backed up (just not to the network drive).
Hopefully the mount volume command is easy to figure out. In my script
it uses
AppleShare to mount the jennifer_data volume of jennifer.tgd-inc.com.
Naturally
that's not my actual password. With Apple's iDisk you should be able to
mount
your folder with "afp://idisk.apple.com/<username>" as the mount
volume,
although I haven't tried it.
The open file command tells the Finder to Open the file. Usually you
can also
{tell application "<application name>"; launch} to start an
application, but
that doesn't seem to work with File Synchronization so I use the
Finder. Once
File Sync is started the script waits 900 seconds, or fifteen minutes.
There are no Finder commands to quit an application, so you have to
tell the
application to quit itself. That's what the {tell application "File
Sync.."}
block does. No matter where it is in the File Sync process, the control
panel
will quit, although perhaps generating an error. The error is no
problem in
OS 9 since Finder errors aren't model any longer; but it could stop
your Mac
if you use an earlier OS, so I recommend OkeyDokeyPro which
automatically
hits RETURN in modal dialog boxes.
|