这是我的情况。
用户A 目前已登录计算机A 。
用户B 通过ssh登录计算机A 。
用户B 通过终端运行osascript(osascript -e 'set volume 0'
)
这是我的错误日志:
Oct 20 13:25:17 osascript[29389] <Error>: Set a breakpoint at CGSLogError to catch errors as they are logged.
Oct 20 13:25:17 osascript[29389] <Error>: This user is not allowed access to the window system right now.
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
2015-10-20 13:25:17.196 osascript[29389:1503684] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2015-10-20 13:25:17.197 osascript[29389:1503684] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2015-10-20 13:25:17.197 osascript[29389:1503684] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
2015-10-20 13:25:17.197 osascript[29389:1503684] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Oct 20 13:25:17 osascript[29389] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
旁注 用户B设置为admin
曾几何时,我记得在没有任何错误之前执行这种情况。不确定这是否是具有权限的 ARD设置?
答案 0 :(得分:1)
我找到了一个似乎有用的替代方案......
如果我添加
在sudo -u username
命令之前 osascript -e
,然后它就可以了。
示例强>
sudo -u username osascript -e 'set volume 0'
从阅读内容看来,当其他用户登录时,苹果似乎不允许用户通过ssh会话打开应用程序。必须以当前用户身份登录才能运行osascripts
否则,添加以下命令sudo -u username