Can't get around "mount failed" - "on error" won't do it - help appreciated

Hi
I'm using this syntax to mount a volume, and it works well if the volume can in fact be mounted:
try
mount volume "afp://username:password@NNN.NNN.NNN.NN/MyDir"
on error
display dialog "blah blah"
end try

BUT, if the volume can't be mounted because the directory specified is incorrect, I a dialog saying "Mount Failed" opens with the only option being 'OK'. Under some other mount failure circumstances this dialog doesn't appear, and the script does eventually time out and disappear all by itself. But if this dialog appears, I have no option other than to manually press OK. It stays open forever. This dialog appears before the script passes the error to the display dialog part, so it prevents the "on error" part of the script from running. This is the only example I know of where 'on error' fails to let the scripter move on and manage the error.

What I would really like to do is to get the 'on error' functionality to actually work properly, because I can determine the PID of the process using Terminal and could then kill it using a shell script if , BUT none of this is possible because the script never gets to the 'on error' state because a real human must press the dialog's OK. I can't seem to use system events to send anything to it because the whole applescript just hangs at this point until the OK is checked.

Does anyone know a workaround? I've tried using a with timeout step around the whole thing but also won't work.

Thanks for any advice you could give me.
Chris.

PB_G4_1.5, Mac OS X (10.4.6)

Posted on May 24, 2007 3:39 AM

Reply
5 replies

May 24, 2007 8:59 AM in response to ctzsnooze

my first thought is to ignore the application responses like so:

ignoring application responses
tell application "Finder" to mount volume "afp://username:password@NNN.NNN.NNN.NN/MyVolume"
end ignoring

I first tried it without telling the Finder to do it, but found that it never got past the mount volume command. This doesn't throw an error that you can catch with a try/on error/end try block, but you could perhaps try the mount command, wait a couple seconds and then test for the desired volume some other way.

I'd be interested to know what you end up going with, since this is the sort of thing I'd be likely to use.

Powermac G4 Dual 867 / 1GB / 330GB / ComboDrive (broken) Mac OS X (10.4.9) 17" Studio Display / 20GB iPod (2nd gen) / Pismo running server duty

Jul 26, 2007 1:54 PM in response to ctzsnooze

I'm having the same trouble, but for different reasons. I was trying to determine a method for examining all the mounted volumes on my desktop and then detecting which mounted volume came from which network server. There doesn't seem to be any way to determine this via any filesystem metadata or anything. The only solution that I could think of was to build an afp url for each server/volume combination for any given mounted volume I wanted to test and then try mount volume on each url (thinking that the on error handler would trap the errors and then I could branch accordingly). Doesn't work. It's interesting that if you try mount volume afp://validerserver/badvolume, you get the mount failed error before your on error handler kicks in. If you try mount volume afp://badserver/validvolume, the on error handler fields the resulting -35 error. If you try mount volume afp://emptystring, you get a connection failed dialog before the on error handler again. Really annoying.

I filed a bug on this.

Apr 6, 2010 8:38 PM in response to ctzsnooze

Hi
This works in 10.6:

set giveup to "0"
set listdisks to ""
set sharepoint to "myshare"
set afp to "afp://user:pass@myserver.com/"
set mountme to afp & sharepoint as text

tell application "Finder"
activate
make new Finder window
set toolbar visible of Finder window 1 to true
set position of Finder window 1 to {80, 80}
set bounds of Finder window 1 to {80, 80, 800, 800}
set current view of Finder window 1 to column view
end tell

repeat until giveup > "5"
set listdisks to list disks
if listdisks contains sharepoint then
set giveup to 6
else
try
mount volume mountme
end try
delay 1
end if
set giveup to giveup + 1
end repeat

tell application "Finder"
set target of Finder window 1 to sharepoint
end tell

Chris

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't get around "mount failed" - "on error" won't do it - help appreciated

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.