Applescript to mount Samba (smb) shares

14 Mar

I have the following apple script to mount samba shares from a Linux Samba server to the Mac OS Sierra

repeat with i from 1 to 5
        do shell script "ping -o -t 2 server.ip.address"
        exit repeat
    on error
        delay 5
        if i = 5 then error number -128
    end try
end repeat

tell application "Finder"
        mount volume "smb://username@server/sharae1"
        mount volume "smb://username@server/sharae2"
    end try
end tell

The reason i'm pinging the server is because the network is slow to start on the Mac. If yours is fast just remove that part.


I found the Script Editor in Applications/Utilities. Save the script then Export it as Application. I did not select any other options.


I am running the Samba 3.6.25 version installed via brew.



Posted ed_mann in Computers & Technology