我的远程 Mac 上有下一个脚本:
on run
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502"
delay 5
tell application "System Events"
keystroke "mypassword" & return
delay 4
keystroke tab
keystroke return
end tell
end run
如果我通过 VNC(在 cmd 中)登录时运行该脚本osascript <script name>
,它可以正常工作,但是当我通过 ssh 运行它时它不起作用。我注意到这只是do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502"
我的问题,另一行通过 ssh 工作。
那么,我不能在远程 Mac 上通过 ssh 使用 CGSession 吗?