使用bashshell等待新的终端,直到从原始终端退出
我正在制作CI构建程序。 我使用三个脚本 首先是建造。其次是资产建设。最后一个用于运行第一个和第二个脚本。 我想等待第一个和第二个脚本,直到它们在最后一个脚本中完成。 这是测试脚本 第一稿使用bashshell等待新的终端,直到从原始终端退出,bash,shell,terminal,Bash,Shell,Terminal,我正在制作CI构建程序。 我使用三个脚本 首先是建造。其次是资产建设。最后一个用于运行第一个和第二个脚本。 我想等待第一个和第二个脚本,直到它们在最后一个脚本中完成。 这是测试脚本 第一稿 #!/bin/sh sleep 1 echo test2 exit 0 #!/bin/sh open -a /Applications/Utilities/Terminal.app ./screenTest2.sh & open -a /Applications/Utilities/Terminal
#!/bin/sh
sleep 1
echo test2
exit 0
#!/bin/sh
open -a /Applications/Utilities/Terminal.app ./screenTest2.sh &
open -a /Applications/Utilities/Terminal.app ./screenTest3.sh &
wait
echo test
第二稿
#!/bin/sh
sleep 1
echo test3
exit 0
最后的剧本
#!/bin/sh
sleep 1
echo test2
exit 0
#!/bin/sh
open -a /Applications/Utilities/Terminal.app ./screenTest2.sh &
open -a /Applications/Utilities/Terminal.app ./screenTest3.sh &
wait
echo test
我如何等待新的终端或脚本。我刚加入OS X。你能简单地解释一下这个解决方案吗?Bash指令是顺序的,只需删除每行末尾的“&”字符。每条指令将一条接一条地执行。您也可以安全地删除wait,无需等待。我想构建并行,所以我使用了&因此我不理解您的问题,您的脚本运行良好。您能解释一下您认为您的方法有什么问题吗?我想知道新终端上shell脚本的pid。我找到了pgrep命令。那就找不到子进程了。我像“pgrep-f/users/blah/command.sh”一样使用它。谢谢你的帮助