Hello,
I need to ensure that a remote volume on a local Appletalk network remains mounted at all times. I want a script that will repeatedly check or (“list disks”) at a specified interval and then mount the volume if at any time it is determined to be unmounted but only then. I have a couple code chunks already but can’t figure out the repeating and the if/then sections.
tell application "Finder"
list disks
end tell
mount volume "afp://usr:passwd@192.168.x.xx/VolName/"
You can use an idle handler to periodically run code (in this case, check for the existence of a disk.
To verify if the disk is mounted, something like this should work:
set mountedDisks to list disks
if mountedDisks does not contain "VolName" then
mount volume "afp://usr:passwd@192.168.x.xx/VolName/"
end if
If you incorporate this inside an idle handler, it will run periodically:
on idle
set mountedDisks to list disks
if mountedDisks does not contain "VolName" then
mount volume "afp://usr:passwd@192.168.x.xx/VolName/"
end if
return 60 -- how many seconds before the check runs again
end idle
Thanks, that looks like what I needed. However, when i just run the code with the idle and the if statements, nothing happens. The disk doesn’t mount(which it should since it is not currently mounted) and I get no errors, etc.
Do I need additional code in the script besides the idle section? Also, another thing I was wondering was what happens if the remote volume is not available for some reason? Will the script generate an error and stop all together? How can I make it so that it the script will just try again later?
thanks again
When I need to mount a remote volume using applescript, I call an internet shortcut to the remote volume. An easy way to make one is to type the url in a browser (afp://usr:passwd@192.168.x.xx/VolName/), and then drag the address to the desktop.
Then ask the finder to open the shortcut file.
on idle
set mountedDisks to list disks
if mountedDisks does not contain "VolName" then
tell application "finder"
open "Path:to:your:shortcut"
end if
return 60 -- how many seconds before the check runs again
end idle
It’s not as tidy as having the code in one file, but it has proven to be more reliable for me.
Has anyone figured out how to automount using this script without getting the kerberos login window (on server using DS)?
The script works fine, but it launches the kerberos agent window first then if you hit the cancel button it switches to the normal login window and mounts the volume just fine. I’d like to be able to default to the normal login window. Thoughts?
set mountedDisks to list disks
if mountedDisks does not contain “VolName” then
mount volume “afp://usr:passwd@192.168.x.xx/VolName/”
end if