我可以使用以下方法将smb共享挂载到/Volumes
osascript -e "mount volume \"smb://user:pass@hal/share\""但是,只有在我已经登录到Mac的情况下,这才有效,否则就会出现“未能建立到WindowServer的默认连接”错误。
我可以使用挂载命令挂载到我的主目录中的一个文件夹,不管我是否登录,这个文件夹都能工作:
mkdir ~/test
mount -t smbfs //user:pass@hal/share ~/test但是我不能用/Volumes来做这件事,因为它是根用户拥有的。osascript调用如何获得写入根用户拥有的文件夹的权限,以及如何不使用AppleScript进行相同的操作?
谢谢
发布于 2021-01-22 09:58:24
回答我自己的问题:
我最初使用的AppleScript是:
osascript -e 'tell application "Finder" to mount volume "smb://user:pass@hal/share"'这会产生不同的错误,当用户未登录时,挂载将失败:
29:78: execution error: An error of type -610 has occurred. (-610)在撰写这个问题时,我发现了不使用Finder的更简单的版本:
osascript -e ‘mount volume "smb://user:pass@hal/share”’如前所述,当用户没有登录时,这也会产生一个错误:
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.但是它确实在/Volumes中挂载了网络共享,所以我可以使用它来忽略错误。
https://stackoverflow.com/questions/65832583
复制相似问题