RSS
 

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
    try
        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"
    
    try
        
        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.

 

Leave a Reply

 

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code,samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>