问题描述
这是我的情况.
用户A 当前已登录计算机A .
用户B 通过ssh登录到计算机A .
用户B 通过终端运行osascript(osascript -e 'set volume 0'
)
User B runs via terminal a 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设置为管理员
Side notesUser B is set as admin
从前,我记得在没有任何错误的情况下执行这种情况.不确定这是否是具有权限的 ARD设置?
Once upon a time, I recall executing this situation before without any errors. Not sure if this is a ARD setting with privileges?
推荐答案
我找到了一种似乎可行的替代方法...
I've found an alternative which seems to work...
如果我添加
sudo -u username
,则它起作用.
示例
sudo -u username osascript -e 'set volume 0'
从看来,Apple不允许用户在另一个用户登录时通过ssh会话打开应用程序.必须以当前用户身份登录才能运行osascripts
,添加以下命令sudo -u username
from what a read, seems that apple does not allow users to open applications via ssh session while another user is logged in. Must be logged in as the current user to run osascripts
, otherwise, add the following command sudo -u username
这篇关于osascript设置音量无法通过ssh进行工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!