How To Find Out if Your Computer is Connected to a Server

Currently, the info(“volumes”) function only returns a list of local drives to which one’s computer is connected. It does not include file servers. (There is a bit bucket issue on this.) Until that is changed, does anyone know how I can test to see if a file server is connected? (I want to force the user to connect before the procedures runs, which includes copying a file to the file server and opening files there.)

You could use an AppleScript with the applescript statement to check for connected disks:

tell application "Finder"
    set mounted_Disks to list disks
end tell

You could also use an expanded version of the script to automatically mount the server if it is missing:

tell application "Finder"
          set mounted_Disks to list disks
         if mounted_Disks does not contain "MyServerDisk" then 
                   mount volume "path to MyServerDisk" as user name "***" with password "***"
        end if
end tell

If you use the first version you will need to check the result returned from the script for the existence of the server disk. The extended version should just do the checking for you and the mounting if needed. These are scripts I found online and have not checked them myself, so use with caution.

Thanks Gary. The first part works. I will try the second part later when I can connect to the server. Tom