mac下开机自动执行sudo命令的方法
作者:
zbmzly | 来源:发表于
2020-08-16 10:56 被阅读0次
参考https://technology.siprep.org/running-sudo-commands-in-automator/#:~:text=If%20you%27re%20wondering%20how%20to%20run%20sudo%20%28for,over%20to%20the%20workflow%20area%20on%20the%20right.
1 打开mac中的Automator程序
![](https://img.haomeiwen.com/i3501797/7bfc03eb539d07b1.png)
截屏2020-08-16 上午10.54.57.png
2 创建一个“应用程序”
![](https://img.haomeiwen.com/i3501797/25c782c73bef1db3.png)
截屏2020-08-16 上午10.55.30.png
3 点击“运行AppleScript”这个action,拖动到右侧面板
![](https://img.haomeiwen.com/i3501797/6bcc3992f00bd9f6.png)
sudoautomator01.png
4 输入运行sudo的命令,比如
do shell script "sudo whatevercommandyouwanttorun" with administrator privileges
如果你要运行一个脚本,运行:
do shell script "sudo /path/to/youractualscript.sh" with administrator privileges
![](https://img.haomeiwen.com/i3501797/5a650e973029ee01.png)
sudoautomator02.png
5 保存这个“应用程序”
![](https://img.haomeiwen.com/i3501797/c117a0aa0361427c.png)
sudoautomator04.png
6 尝试打开这个应用程序,测试他的可用性。这时应该会提醒你输入密码,因为你执行了sudo
命令。
7 在系统偏好设置------用户与群组------登录项中,添加刚保存的application
本文标题:mac下开机自动执行sudo命令的方法
本文链接:https://www.haomeiwen.com/subject/fttzdktx.html
网友评论