I know I can mount Samba share using either mount or open command from the terminal shell. See this related question: How can I mount an SMB share from the command line?. I prefer using open because it mounts the shared folder under /Volumes which seems kind of OS X standard, the expected thing. Namely this happens by typing

open "smb://guest:@${host}/${path_component}"

(where ${host} is the host name or IP address of the Samba share and ${path_component} is the path or "name" of the Samba share). The result and the main thing is that I can access the stuff from /Volumes/${path_component}. This is very nice indeed. Just there are two problems or nuisance doing this from within scripts. The first is that this will open a superfluous progress indicator and then Finder window. The second, lesser one as there are scriptable work-arounds, is that the command returns immediately without waiting for the mount to be really available.

Is there a way to (synchronously) mount Samba shares under /Volumes without extraneous windows popping up?

(I am using the latest OS X (Sierra).)

1 Answer 1


The following is what I use to mount Samba shares via launchd:

/usr/bin/osascript -e "try" -e "mount volume \"smb://guest@${host}\"" -e "end try"

Using osascript's mount means any keychain access needed is done "automagically", there's no progress indicator or Finder window, and the command waits for the mount to be available before proceeding (try it with && echo -n "Done."; mount appended to the end of the above command to test this).

  • 2
    OSA script? That's some weird stuff, but it works just like I want it to! Thanks!
    – FooF
    May 5, 2017 at 10:29
  • @FooF osascript is the command line interface for AppleScript. May 6, 2017 at 0:17
  • Perfect. For shares needing authentication, you can replace smb://guest@$host with smb://username:password@$host in the above command.
    – mivk
    Jul 19, 2018 at 14:15
  • Loved this answer, but now...my smb share has changed hosts..how do we update this script? Plus, not sure if this is standard, but /usr/bin/osascript is currently inaccessible to me for modification...even if I sudo. This is my work laptop, so it is entirely possible that my employer has locked this down since I first executed this script and I may just have to deal with the error dialog when the mount fails. Apr 17, 2019 at 18:25
  • It works, except even when I add password it still asks for one. A window pops open and asks me to enter password
    – ktyagi
    Jun 20, 2019 at 14:36

You must log in to answer this question.

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