I’m trying to write a script that will mount a network volume that’s needed by filemaker. This script runs automatically when I open the filemaker database file. It works fine, unless the network volume is unavailable or takes too long to mount. Here’s the script I’ve got so far - pretty simple:
--> Check if video volume is mounted: if not, then mount it
tell application "Finder"
if not (exists disk "Video") then
mount volume "afp://macserver:video@192.168.254.20/Video"
end if
end tell
--> Switch to FileMaker
tell application "FileMaker Pro Advanced"
activate
end tell
This script runs automatically when the filemaker database is opened. The database relys on this volume being mounted for SOME of it’s functions, but it’s not absolutely necessary to have the volume mounted to work in the databse.
Here’s the problem - say the remote volume is unavailable for whatever reason. First off, it keeps finder busy for two whole minutes (spinning beach ball) until Finder times out trying to mount the volume. (unacceptable). Also, it keeps Filemaker from being accessible until the script itself times out (one minute) - so the user has to wait for the script to time out before the database becomes accessible.
I’ve tried using “do shell script” to mount the volume behind the scenes via terminal without keeping finder occupied, but apperently for terminal to mount the volume, the mountpoint has to pre-exist. I could use a shell script to create the mountpoint, but that’s a mess - if the volume is already mounted, it’s mountpoint can vary (mount, mount-1, mount-2 etc) depending on if the OS cleaned up the /Volumes folder properly - happens all the time. Also, that process involves unmounting, (inturrupting the user), creating a new mountpoint, then remounting to that mountpoint. Either way, it’s messy.
What I’m looking for is a way to get the user into filemaker immediately so they can work while it mounts the volume in the background, without keeping Finder busy, and then returns an error mesage that I can trap and display should the volume not be able to be monted.
I’ve tried variations and combinations of ‘with timeout’ and ‘try’, but I think I lack the understanding of how these command work. I considered a subroutine, but if I remember correctly, the sript waits for the sub to complete before continuing.
Any help?
thanks in advance!