linux - 在脚本中运行另一个

标签 linux bash shell

我必须在脚本中运行另一个终端并等待函数在该终端上执行 在执行 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/

相关文章:

windows - 将可加载插件链接到 Linux 和 Windows 上可执行文件中的符号

linux - 为什么 perf stat 将 "stalled-cycles-backend"显示为 <不支持>?

linux - 通过一个命令或一系列命令访问数据中心中的所有机器

bash - 实时修改 `tail -f`输出

bash - 如何在 shell 脚本中提取字符串的前两个字符?

macos - 如何创建 Bash 别名?

linux - Bash 脚本忽略 if, then 语句;每次返回相同的结果

bash - 如何显示 zsh 函数定义(如 bash "type myfunc")?

linux - bash 上的 GAMESS 配置脚本错误 : syntax error near $<

node.js - 在 EC2 : sudo node command not found, 但没有 sudo 的 Node 可以