首页 > 解决方案 > How to create a script that opens multiple terminals and runs different programs on them?

问题描述

Good day everyone,

I am working on a project that requires me to have 7+ programs (no GUI, runs on shell) open, all interacting with each other. For example, Program 1 asks a question to Program 2, and it uses Program 3 and 4 to solve that etc.

所以我要做的是,我打开许多终端并在不同的终端上运行每个终端,然后将它们放在我的屏幕上并继续。但这是一个麻烦的过程,因为每次我需要重新编译时,我都需要一个一个地运行它们,更糟糕的是,如果我关闭计算机,我需要打开许多 shell,进入目录,运行它们都是某某。

我想要的是一个文件,它可以为我打开必要的终端窗口并转到每个窗口的正确目录,然后运行程序。我对 shell 脚本了解不多,但我认为这一定是可能的。你能给我任何指示吗?请注意,程序不应在后台或不同选项卡中运行。我需要经常观察显示器。

我读过这篇关于类似问题的帖子,但这对我不起作用,因为我需要在不同的终端上使用它们。

谢谢你。

标签: linuxbashshell

解决方案


我们假设您正在使用gnome terminale,因此命令将是:

gnome-terminal --working-directory "{{APP_FOLDER}}" --command "{{APP_EXCUTABLE}}"

这种方法可以应用于任何其他终端仿真器。


推荐阅读