macOS: mount SMB volume display name

I’m developing a shell script to deploy a Xojo Web app to a server running macOS.

Part of the script mounts the server as a remote volume:

open smb://$user:$password@myserver-M1.local/myfolder"

This works great, except the Finder shows the server as
myserver-M1.local

whereas if I double-click the server from the Finder’s Network sidebar, then the server shows as
myserver M1

In all cases, the server’s folder is mounted properly:

/Volumes/myfolder

This is a very minor cosmetic issue, but I’m wondering:

  • is there a way to mount a SMB server in macOS to have the display name match, so it doesn’t show the “.local” part, and I don’t end up with two instances showing in the Finder / Locations sidebar?

image

what if you try

open smb://$user:$password@myserver-M1/myfolder"

Is it still using SMB when you do this? I suspect not and that it’s afp.

Good idea, but both sides are running 12.6, and there is no more AFP sharing in macOS any longer:
image

Well, I was 99% sure I tried that and it failed, but I just tried again this morning and it worked! My server name is upper & lowercase, and I think I might have had a typo?

To clarify: it appears that you do not need the .local part, but if your server name has a space in the name, you have to replace the space with a dash (-) to get it to work.

So if your server name is:
MyServer M1
this name is set via System Preferences / Sharing / File Sharing / Computer Name

you would open the smb URL as

open smb://user:password@MyServer-M1/myfolder

where ‘myfolder’ is the name of a folder shared on the server.

This appears to have the same end results as double-clicking the server name from within the Finder’s Network tab.

1 Like

If you use MBS Xojo Plugins, you can use NetFSMountMBS class to mount something, even asynchronously.
And we also got a MountMBS and a MacMountServerVolumeMBS function.

in the sharing pane, just under the editfield where you type the name of the mac, you validate, and it indicates you the name of the remote device.

True, but the question is - can you access it via SMB without appending .local - turns out you can.

From a Mac you can, anyway.

Good point - my guess is some sort of Bonjour magic?

Or the OS just doing the translation for you