Linux 我想在不同的选项卡/终端上运行同一shell脚本中的一些命令

Linux 我想在不同的选项卡/终端上运行同一shell脚本中的一些命令,linux,bash,shell,terminal,scripting,Linux,Bash,Shell,Terminal,Scripting,我实际上想在不同的选项卡或终端上运行相同脚本的一些命令,因为这些命令正在激活服务器并侦听不同的端口。因此,他们必须始终保持活跃。另外,我希望有一个对选项卡或终端的引用,以便稍后在脚本结束时关闭它们。请帮忙 我尝试了一个简单的脚本测试,看看是否可以找到打开其他选项卡的方法: tab=" --tab" options=() cmds[1]="echo Banana" cmds[2]="echo Cat" for i in 1 2; do options+=($tab -e "bash -c

我实际上想在不同的选项卡或终端上运行相同脚本的一些命令,因为这些命令正在激活服务器并侦听不同的端口。因此,他们必须始终保持活跃。另外,我希望有一个对选项卡或终端的引用,以便稍后在脚本结束时关闭它们。请帮忙

我尝试了一个简单的脚本测试,看看是否可以找到打开其他选项卡的方法:

tab=" --tab"
options=()

cmds[1]="echo Banana"

cmds[2]="echo Cat"


for i in 1 2; do
options+=($tab  -e "bash -c \"${cmds[i]} ; bash\"" ) 
done

gnome-terminal "${options[@]}"

exit 0
但我得到的结果是:

./test.sh
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.

有办法打开标签吗?并获取每一个的引用,以便在处理完成后可以关闭与服务器相关的命令?

这是我为man gnome终端找到的;我想那会有帮助的,谢谢

gnome-terminal(1)           General Commands Manual          gnome-terminal(1)

NAME
       gnome-terminal — is a terminal emulation application.

SYNOPSIS
       gnome-terminal  [-e,  --command=STRING]   [-x,  --execute ]  [--window-
       with-profile=PROFILENAME]  [--tab-with-profile=PROFILENAME]  [--window-
       with-profile-internal-id=PROFILEID]       [--tab-with-profile-internal-
       id=PROFILEID]    [--role=ROLE]    [--show-menubar]     [--hide-menubar]
       [--geometry=GEOMETRY]  [--working-directory=DIRNAME]  [-?, --help]

DESCRIPTION
       GNOME  Terminal is a terminal emulation application that you can use to
       perform the following actions:

       Access a UNIX shell in the GNOME environment.

       A shell is a program that interprets and executes the commands that you
       type  at  a  command  line  prompt.  When you start GNOME Terminal, the
       application starts the default shell that is specified in  your  system
       account. You can switch to a different shell at any time.
OPTIONS
       -e, --command=STRING
                 Execute the argument to this option inside the terminal.

       -x, --execute
                 Execute  the  remainder of the command line inside the termi‐
                 nal.

       --window-with-profile=PROFILENAME
                 Open a new window containing a tab with  the  given  profile.
                 More than one of these options can be provided.

       --tab-with-profile=PROFILENAME
                 Open  a  tab  in the window with the given profile. More than
                 one of these options can be provided, to open several tabs .

       --window-with-profile-internal-id=PROFILEID
                 Open a new window containing a tab with the given profile ID.
                 Used internally to save sessions.


您可以使用名为
tmux
的程序。这是一个terminal-multiplexer,就像屏幕一样。使用它,您可以在同一终端窗口中打开不同的会话和窗口(类似于选项卡)。它们可以通过脚本按名称或id引用

很可能,Linux发行版的包管理器具有
tmux


注:我必须发布一个答案而不是评论,因为我没有足够的评论声誉。

我建议看一下
人机界面
。找不到屏幕手册。您将要安装
屏幕
tmux
,它们不是大多数操作系统上标准基本安装的一部分,但通常由管理员安装。如果你必须选择其中一个,许多人建议
tmux
更现代、更模块化。你可以在谷歌上找到所有标准实用程序的手册页面,如果你没有在本地安装,还可以找到许多可选页面。这是,这是。但是,正如您可能知道的,手册页只是参考,而不是教程。也许可以先找一本你感兴趣的教程。