Re: Mount AFP if Not already?
Re: Mount AFP if Not already?
- Subject: Re: Mount AFP if Not already?
- From: Emmanuel Levy <email@hidden>
- Date: Sat, 21 Feb 2009 11:56:39 +0100
Title: Re: Mount AFP if Not already?
Jim's script is certainly very good, and there's no harm using do
shell script mkdir and mount but it's not true for me that "the
Finder 'mount' command is super flaky". First it's a command in
StandardAdditions, not a Finder's command (maybe using it in a tell
Finder block makes it super flaky, I don't know). Then, our systems
use it in industrial contexts and I don't see something wrong with
it.
Only problem is, I don't know a reliable way to know whether a
given IP is mounted (I'm afraid your script won't do any good in
circumstances where you have to mount several volumes with the same
name). So, we install a specific file in the root of each volume, and
we test for that file.
Emmanuel
At 2:39 PM -0600 2/20/09, Jim Skibbie wrote:
I use the below two handlers to mount
volumes as the Finder 'mount' command is super flaky when trying
to mount remote volumes. The downside is that you have to provide user
and password credentials in the script, so there are security issues
to consider.
The handler determines if the volume is mounted, if not, it makes a
folder in /Volumes, then makes a mount point to it:
set needed_vols to {"VolumeName1",
"VolumeName2"}
set
serverpath to "afp://username:password@ServerIP/"
set
NoOfTries to 5
persistentMount(needed_vols,
serverpath, NoOfTries)
on
persistentMount(vols_to_mount,
Server_Path, max_tries)
set mounted_vols to list
disks
set attempts to 0
repeat until
(check_list_containment(vols_to_mount,
mounted_vols))
repeat with
vol in
vols_to_mount
if
mounted_vols does not
contain vol
then
set mount_url to
(Server_Path &
vol) as string
try
do shell script "mkdir -p /Volumes/"
& quoted form of (vol as string)
do shell script "mount -t afp "
& quoted form of mount_url & " /Volumes/"
& quoted form of (vol as string)
on
error errMsg
number errNum
if errNum is -128 then error
number -128
end
try
end if
end repeat
set
mounted_vols to list disks
if
check_list_containment(vols_to_mount, list
disks) then return
set attempts to attempts +
1
if (attempts
> max_tries)
then ¬
error ("ERROR: file server may be down.
#persistentMount tried " & ¬
attempts & ¬
" times to mount the
required servers" as string)
end repeat
end persistentMount
-- check if each item in aList is in
aContainer
-- return false if not
on
check_list_containment(aList,
aContainer)
repeat with i in aList
if i is not in
aContainer then return false
end repeat
return true
end check_list_containment
William J Sisti said:
I am looking for an apple scrip tor application that will
determine if X
afp share is mounted and if not mount it. Is there something
like that
already out there or something we would have to script myself?
-Will
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
>atimage.fr
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden