我必须在脚本中运行另一个终端并等待函数在该终端上执行 在执行 shell 脚本中的下一个命令之前。场景如下
脚本.sh
!/bin/sh
...
...
gnome-terminal --working-directory=#{image_path} -e ./test.sh # execute test.sh script on another terminal
./switch 0 0 # I have to execute this command after test.sh script gets completed on another terminal
...
...
问题来了。 test.sh 脚本未完全执行并立即返回到父脚本并执行 ./switch 0 0
命令。由于此 ./switch 0 0
命令取决于 test.sh
脚本完成,因此我的脚本失败了。
问候 曼尼什 B.
最佳答案
我不确定 gnome-terminal 中是否有一个开关可以让它同步运行,但你可以使用 xterm 来实现。与其他终端不同,Xterm 不会进入后台:
( D=$(pwd); cd "$image_path"; xterm -e "$D/test.sh" )
./switch 0 0
关于linux - 在脚本中运行另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18805993/