Shirt Pocket Discussions

Shirt Pocket Discussions (https://www.shirt-pocket.com/forums/index.php)
-   General (https://www.shirt-pocket.com/forums/forumdisplay.php?f=6)
-   -   auto-disconnect "server" after copying files (https://www.shirt-pocket.com/forums/showthread.php?t=2378)

afragen 05-11-2007 06:18 PM

Chris,

Your hacks are beautiful. In some preliminary testing here with multiple AFP mounts, the perl version (the only one I'm testing), works great. Just so you know here's what some of my afp mount points look like from the mount command.

Quote:

afp_003Js12XIRWg001Eic06SdO0-1.2d000054 on /Volumes/Backup (nodev, nosuid, mounted by afragen)
afp_003JrO1u5JvO001Eic06SdO0-1.2d000055 on /Volumes/AJF Photo (nodev, nosuid, mounted by afragen)
I was also trying to come up with a solution and think I've found another, less elegant way.

Code:

  if [[ `mount | awk '/^afp_/'` != "" ]]; then
    mount | awk '/^afp_/ {print $3}' | xargs -n 1 umount -f
    num_mounts=`mount | grep -c ^afp`
    for (( i = 0; i < $num_mounts; i++ )); do
      mountpt=`mount | grep ^afp | grep -o '/.* (' | sed 's_/Volumes/__g' | sed 's_ (_:_g' | head -1`
      cmd='tell application "Finder" to eject '\"$mountpt\"
      osascript -e "$cmd"
      sleep 2
    done
  fi

As I'm not nearly as adept I found that mixing in a little AppleScript to eject the Volumes with spaces works too. I too made the assumption about parens, but my assumption was that parens wouldn't be in a volume name and would be immediately after the mount point listed in the mount command. Probably not very good assumptions on the whole.

I really hope this gets indexed by Google as I've been trying to find a way to automatically unmount any connected drives when I switch locations on my laptop. BTW, I did figure that out. :) It involves a small shell script and a launchd process.

Of course, if there was some way to get the mount point from SD then we wouldn't have to go through all these contortions. But the exercise still helps me for the other script.

Andy

afragen 08-21-2007 01:55 PM

Dave, could you post the contents of the 'mount' command when SMB shares are mounted? I'm trying to adapt my unmount script to handle afp, sshfs and smb shares. Unfortunately I don't have sshfs or smb shares to test with. TIA.

BTW, the script is always up at http://thefragens.com/pub/


All times are GMT -4. The time now is 02:16 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.