I am trying to add a “mount volume” to a script I’m working on so I can then copy folders to it. In keeping with smart scripting, I am trying to catch any errors that may pop up; specifically in case the computer to be mounted is offline.
During testing, when I have the volume to be mounted off (in my case a G4), my script just hung there and eventually crashed the Finder (I’ve never even seen that happen before!).
Today, I tried adding a “timeout” & “error number -1712” to solve the issue but it still hangs, though it no longer crashes the Finder. Any suggestions?
set IPServerAddress to "###.##.###.###"
set volumeName to "G4Server"
set theUserName to "user"
set thePassword to "password"
set mountG4 to mount volume volumeName on server IPServerAddress as user name theUserName with password thePassword
tell application "Finder"
try
with timeout of 15 seconds
if not (exists disk "G4Server") then
mountG4
end if
end timeout
on error number -1712
display dialog "The G4Server is not available for connection.
To try again, please make sure the G4 is on and then click Retry.
If you would like to use your own computer to upload this art, click Mine. (NOTE: If you choose this option, the script will NOT send an email to the printer to notify them of the FTP upload.)
Click Cancel to quit." buttons {"Retry", "Mine", "Cancel"} default button {"Retry"}
set mountButton to the result
if mountButton is "Retry" then
set repeatLoop to true
repeat while repeatLoop is true
try
with timeout of 15 seconds
mountG4
end timeout
if (exists disk "G4Server") then set repeatLoop to false
on error number -1712
display dialog "The G4Server is still not responding.
Be sure the G4 is on and then click Retry or Cancel to exit this script." buttons {"Retry", "Cancel"} default button {"Retry"}
set loopButton to the result
if loopButton is "Cancel" then
return
end if
end try
end repeat
else if mountButton is "Mine" then
display dialog "The WorkStation script would now execute."
else if mountButton is "Cancel" then
return
end if
beep 3
end try
end tell