Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There's a myriad of possibilities for mounting shares upon Login within OSX. I'm after having it done when a network connection is restored.


  • Mount the share
  • connection lost
  • connection re-gained
  • Mount the share again (if possible), otherwise, don't - i.e. different location.

Any idea as to how to make this happen?

Am exploring the possibility using NFS shares from the DroboFS, but would prefer to keep it to CIFS/AFP.

Suggestions are welcome.

Thank you.

share|improve this question

You could try something like this:


while :                                                                                        
    ping -t 1 > /dev/null 2>&1                                                      

    if [[ $exit_status == 0 && $last_status != 0 ]]; then                                      
        osascript -e 'tell application "Finder"' -e 'eject "share"' -e 'end tell'                  
        osascript -e 'tell application "Finder"' -e 'open location "smb://server/share"' -e 'end tell'                                                                                      
    sleep 5                                                                                    

We check the internet connection by pinging google, you could change that to a local IP if you don't want to test for internet connectivity. If we can ping google then we tell finder to eject the old mount, and mount a the SMB share again, otherwise sleep for 5 seconds.

It's very dirty but it does what you want, there is a lot of room for improvements.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .