简体   繁体   English

在前台但在其他终端选项卡上运行进程的脚本

[英]Script for running processes in foreground but on different terminal tab

I am new to shell scripting. 我是Shell脚本的新手。 I am using gnome-terminal . 我正在使用gnome-terminal I have written one simple script which I need to start my process one-by-one, Here is my Script: 我写了一个简单的脚本,我需要一个脚本开始一个进程,这是我的脚本:

#!/bin/bash    
    cd A/
    sleep 1
    ./exe1 &
    echo "-------- exe1 STARTED------"

    cd ../../B/
    sleep 1
    ./exe2_a &
    sleep 1
    ./exe2_b &
    echo "--------exe2 STARTED------"

    cd ../C/
    sleep 1
    ./NAV_exe3_a &
    sleep 1 
    ./NAV_exe3_b &
    echo "--------exe3 STARTED------"

As you can see I am starting 5 different processes in the background, but how do I start them in 5 different tabs in terminal (in foreground) by a single script? 如您所见,我在后台启动5个不同的进程,但是如何通过单个脚本在终端(在前台)的5个不同选项卡中启动它们? Is there any way? 有什么办法吗?

If you have gnome-terminal available, you can do something like this: 如果您有可用的gnome-terminal ,则可以执行以下操作:

gnome-terminal \
  --tab -e "./exe1" \
  --tab -e "./exe2" \
  --tab -e "./exe3"

Note that this will start everything in parallel. 请注意,这将并行启动所有内容。 You can implement timed delays using sleep, if you need that sort of thing: 如果需要这种事情,可以使用睡眠实现定时延迟:

gnome-terminal \
  --tab -e "./exe1" \
  --tab -e "sh -c 'sleep 5; ./exe2'" \
  --tab -e "sh -c 'sleep 10; ./exe3'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM