bash 如何在 mac os x 系统中静默安装 dmg 文件(使用 shell 脚本)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21428208/
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
How to silently install dmg file in mac os x system (using shell script)?
提问by user3214224
I have used the following command for dmg file attach and detech
我已将以下命令用于 dmg 文件附加和 detech
hdiutil attach installer.dmg
hdiutil detach installer.dmg
in the dmg file it contains test.app GUI mode installation, i can drag the test.app to application location
在 dmg 文件中,它包含 test.app GUI 模式安装,我可以将 test.app 拖到应用程序位置
What i need is when i double-click the script, dmg containing the app should install automatically to
我需要的是当我双击脚本时,包含应用程序的 dmg 应该自动安装到
application location in mac os x after that terminal window should automatically closed
该终端窗口后的 mac os x 中的应用程序位置应自动关闭
Thanks in advance for your answers
预先感谢您的回答
采纳答案by zmo
well, a shell script like the following should do the job:
好吧,像下面这样的 shell 脚本应该可以完成这项工作:
install_app.sh
install_app.sh
#/bin/sh
VOLUME=`hdiutil attach | grep Volumes | awk '{print }'`
cp -rf $VOLUME/*.app /Applications
hdiutil detach $VOLUME
and you can run it that way:
你可以这样运行它:
% install_app.sh ~/Downloads/MyApp.dmg
be aware that I'm doing no argument checking in that little script, and that any existing app with the same name will get overwritten.
请注意,我没有在那个小脚本中进行参数检查,并且任何具有相同名称的现有应用程序都将被覆盖。
HTH
HTH