bash 从名称中带有空格的服务器挂载 SMB 共享
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15838803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mount SMB share from a server with a space in its name
提问by Jawap
I'm trying to mount an SMB share on the terminal. I'm able do to that, if the server has no space in its name using this command:
我正在尝试在终端上安装 SMB 共享。如果使用以下命令服务器名称中没有空格,我可以做到这一点:
$ mount -t smbfs //user:password@server/resource /Volumes/resource
However in my case the server name has a space and I can't figure out how to properly pass such a name.
但是,在我的情况下,服务器名称有一个空格,我无法弄清楚如何正确传递这样的名称。
I tried using double or single quotes:
我尝试使用双引号或单引号:
$ mount -t smbfs "//user:password@ser ver/resource" /Volumes/resource
mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument
I tried escaping the space:
我尝试逃离空间:
$ mount -t smbfs //user:password@ser\ ver/resource /Volumes/resource
mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument
I also tried using %20, \x20and \040, but I get an error:
我也尝试使用%20, \x20and \040,但出现错误:
mount_smbfs: server connection failed: No route to host
I know I could use the IP address or rename the server, but that would be a workaround and not a solution and I'm wondering what I'm missing.
我知道我可以使用 IP 地址或重命名服务器,但这将是一种解决方法而不是解决方案,我想知道我错过了什么。
回答by Bobulous
What happens if you combine quotes and escape:
如果你结合引号和转义会发生什么:
mount -t smbfs "//user:password@ser\ ver/resource" /Volumes/resource
That reportedly worked for someone when mounting an smbfs volume with a space in the username.
据报道,在安装用户名中有空格的 smbfs 卷时,这对某人有用。

