use*_*224 4 unix macos bash shell
我已使用以下命令进行 dmg 文件附加和 detech
hdiutil attach installer.dmg
hdiutil detach installer.dmg
Run Code Online (Sandbox Code Playgroud)
在dmg文件中,它包含test.app GUI模式安装,我可以将test.app拖到应用程序位置
我需要的是当我双击脚本时,包含该应用程序的 dmg 应自动安装到
mac os x 中的应用程序位置之后终端窗口应自动关闭
预先感谢您的回答
好吧,像下面这样的 shell 脚本应该可以完成这项工作:
#/bin/sh
VOLUME=`hdiutil attach $1 | grep Volumes | awk '{print $3}'`
cp -rf $VOLUME/*.app /Applications
hdiutil detach $VOLUME
Run Code Online (Sandbox Code Playgroud)
你可以这样运行它:
% install_app.sh ~/Downloads/MyApp.dmg
Run Code Online (Sandbox Code Playgroud)
请注意,我在那个小脚本中没有进行任何参数检查,并且任何具有相同名称的现有应用程序都将被覆盖。
华泰