macOS-以root用户身份运行shell脚本时切换到admin user
因此,我有一个name.sh脚本,其中包含大量shell命令。 在脚本结束之前,我需要更改墙纸 我正在使用macOS-以root用户身份运行shell脚本时切换到admin user,macos,shell,terminal,root,Macos,Shell,Terminal,Root,因此,我有一个name.sh脚本,其中包含大量shell命令。 在脚本结束之前,我需要更改墙纸 我正在使用 osascript-e'tell application“System Events.app”将每个桌面的图片设置为“/Library/desktop Pictures/my.jpg” 在队伍的尽头。问题是Apple脚本不会在root下运行。因为系统事件将首先抛出10810,然后抛出600(应用程序未运行)。如果我在admin user下运行这个osascript,它将正常工作。墙纸将被
osascript-e'tell application“System Events.app”将每个桌面的图片设置为“/Library/desktop Pictures/my.jpg”
在队伍的尽头。问题是Apple脚本不会在root下运行。因为系统事件将首先抛出10810,然后抛出600(应用程序未运行)。如果我在admin user下运行这个osascript,它将正常工作。墙纸将被设置
让我知道你们能在这方面帮我什么 如果您已经是
root用户
,您可以随时切换到其他用户帐户。该命令是su
如果您的用户是管理员
su - admin <<\:
osascript -e 'tell application "System Events.app" to set picture of every desktop to "/Library/Desktop Pictures/dneg.jpg"'
:
su-admin