Shawn Janes
asked on
Applescript Question - Mount Drive if NAS is available
Hi,
I am not an Applescripter and I would like some assistance trying to mount my drive without getting the error dialogue box that the drive is not available.
I have a NAS on my network and when I restart the NAS it takes a few minutes for it to be available. During that time I have an AppleScript that tries to run to connect a network shared drive, but when it can't see the NAS it throws an error that I have to click 'ok' on before it will continue to check. My script works fine for mounting but I need help in figuring out how to mount the drive once the NAS is available so I can avoid the error message. Here's some info:
> The NAS is IP address 192.168.2.181.
> The network share I am trying to mount is at 192.168.1.181/fileserver.
> I am using Hazel by Noodlesoft to run this code.
So basically,
If this condition is met
:
if [ -d "/Volumes/fileserver" ]; then exit 1; else exit 0; fi
The go the following:
Here is my script that mounts the drive:
Can I do something like ping the network drive to see if it's available and if it is mount? Not sure exactly how to accomplish this.
Any advice?
I am not an Applescripter and I would like some assistance trying to mount my drive without getting the error dialogue box that the drive is not available.
I have a NAS on my network and when I restart the NAS it takes a few minutes for it to be available. During that time I have an AppleScript that tries to run to connect a network shared drive, but when it can't see the NAS it throws an error that I have to click 'ok' on before it will continue to check. My script works fine for mounting but I need help in figuring out how to mount the drive once the NAS is available so I can avoid the error message. Here's some info:
> The NAS is IP address 192.168.2.181.
> The network share I am trying to mount is at 192.168.1.181/fileserver.
> I am using Hazel by Noodlesoft to run this code.
So basically,
If this condition is met
:
if [ -d "/Volumes/fileserver" ]; then exit 1; else exit 0; fi
The go the following:
Here is my script that mounts the drive:
tell application "Finder"
if not (disk "fileserver" exists) then
mount volume "afp://192.168.2.181/fileserver"
end if
end tell
Can I do something like ping the network drive to see if it's available and if it is mount? Not sure exactly how to accomplish this.
Any advice?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did this help at all?