我有一个脚本,它有两个苹果脚本,可以打开一个新选项卡并执行一个命令。我希望第二个苹果脚本等到第一个苹果脚本的命令行操作完成。在它继续之前,我宁愿不必只睡 x 久。
有没有办法我可以做到这一点?
这是我所拥有的:
osascript -e 'tell application "Terminal" to activate' \
-e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e 'tell application "Terminal" to do script "cd '$current_dir'" in selected tab of the front window' \
-e 'tell application "Terminal" to do script "./my_script arg1" in selected tab of the front window'
------ Wait until this process is finished -------
osascript -e 'tell application "Terminal" to activate' \
-e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e 'tell application "Terminal" to do script "cd '$current_dir'" in selected tab of the front window' \
-e 'tell application "Terminal" to do script "./my_script different_arg1" in selected tab of the front window'