• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Mount AFP if Not already?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mount AFP if Not already?


  • Subject: Re: Mount AFP if Not already?
  • From: Jim Skibbie <email@hidden>
  • Date: Fri, 20 Feb 2009 14:54:05 -0600
  • Thread-topic: Mount AFP if Not already?

Title: Re: Mount AFP if Not already?
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:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Mount AFP if Not already?
  • Next by Date: RE: Mount volume
  • Previous by thread: Re: Mount AFP if Not already?
  • Next by thread: including source code
  • Index(es):
    • Date
    • Thread