Im trying to create an osascript for use with rsync. I need a script to mount a network volume and if the volume cannot be mounted to stop. I can create the script for mounting the volume, but if it cannot mount the volume it continues for ever. Is there anyway to try for some time and then stops?
As the mount volume command displays an alert window with OK button in case of an error,
use the mount_afp shell command. You have to adjust all literal strings except “/bin/ls/Volumes” in the first and second line
If the shared volume is a SMB volume, use the mount_smb command instead, the syntax could be different
if "serverVolume" is not in (do shell script "/bin/ls /Volumes") then
set flag to mountAFP("user", "pass", "server.local", "serverVolume")
else
set flag to true
end if
if flag then
-- do backup
end if
on mountAFP(user_name, pass_word, thehost, theVolume)
set theAddress to quoted form of ("afp://" & user_name & ":" & pass_word & "@" & thehost & "/" & theVolume)
set mountpoint to quoted form of ("/Volumes/" & theVolume)
try
do shell script "/bin/mkdir " & mountpoint & "; /sbin/mount_afp " & theAddress & space & mountpoint
return true
on error
do shell script "/bin/rm -r " & mountpoint
return false
end try
end mountAFP