Macos 如何让shell脚本等待pkg完成安装
我正在尝试运行一个脚本,该脚本将装载dmg,打开pkg,然后卸载Macos 如何让shell脚本等待pkg完成安装,macos,bash,shell,Macos,Bash,Shell,我正在尝试运行一个脚本,该脚本将装载dmg,打开pkg,然后卸载 #!/bin/sh echo "Mounting Volume" hdiutil attach -quiet "/path/to/DMG" echo "Open pkg" open /Volumes/DMG/pkg echo "Unmounting volume" hdiutil detach -quiet /Volumes/DMG exit 0 这就是我目前所拥有的 我希望脚本能够等待pkg完成安装,然后卸载。我使用open
#!/bin/sh
echo "Mounting Volume"
hdiutil attach -quiet "/path/to/DMG"
echo "Open pkg"
open /Volumes/DMG/pkg
echo "Unmounting volume"
hdiutil detach -quiet /Volumes/DMG
exit 0
这就是我目前所拥有的
我希望脚本能够等待pkg完成安装,然后卸载。我使用open而不是installer的原因是sudo需要标准输入,但我正在用户无权访问标准输入的其他地方运行脚本。使用
-W
标志执行open
命令。从手册页中:“使open等待,直到它打开(或已经打开)的应用程序退出。”我认为您可以使用wait
命令。当您想在执行其他命令之前等待程序时,只需添加wait
命令
更多信息:
有效,但需要很长时间,至少30秒才能退出。哦,该死的,我不聪明。命令发出后,我睡了50个觉,因为我正在测试某个东西,但忘了删除它。