macos MAC 命令在终端上运行 .pkg 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5298702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:50:09  来源:igfitidea点击:

MAC command to run a .pkg file on terminal

macos

提问by Jinith

I have a .mpkg file which i want to execute from the terminal I sucessfully used this command to achive this

我有一个 .mpkg 文件,我想从终端执行我成功地使用这个命令来实现这个

sudo installer -pkg Snip.mpkg -target /Applications

But the thing is that when i run this command it ask me for the admin password before performing the installation. Is there a way i can do this without the password or can i provide the password also in my sudo installer command...

但问题是,当我运行此命令时,它会在执行安装之前询问我的管理员密码。有没有办法在没有密码的情况下执行此操作,或者我也可以在我的 sudo 安装程序命令中提供密码...

Also see :- Running .pkg on MAC OS from java code

另请参阅:-从 Java 代码在 MAC OS 上运行 .pkg

please reply

请回复

thanks in advance

提前致谢

回答by hd1

Remove the password requirement from sudousing the following line in sudoers:

使用 sudoers 中的以下行从sudo 中删除密码要求:

jinith ALL=(ALL) NOPASSWD: ALL 

Do note the other solution will add the password to the process list. Mine will make it so that user jinith can run anycommand as anyuser without a password.

请注意,其他解决方案会将密码添加到进程列表中。我的将做到这一点,以便用户 jinith 可以在没有密码的情况下以任何用户身份运行任何命令。

回答by aqua

You should be able to pass in the password from stdin:

您应该能够从stdin以下位置传入密码:

echo <password> | sudo -S installer -pkg Snip.mpkg -target /Applications