简体   繁体   English

如何使脚本文件在ubuntu的多个终端上运行多个命令?

[英]How to make script file to run several commands on several terminals in ubuntu?

I have to open three terminals and each terminal should go to three directories and need to run three files on those three terminals. 我必须打开三个终端,每个终端应转到三个目录,并且需要在这三个终端上运行三个文件。 Now I need speed up my task. 现在,我需要加快工作速度。 Beacuse of that need to do it by running a single script file.How can I do that? 因为需要通过运行一个脚本文件来做到这一点,我该怎么办?

As a example I have to run those three commands on three terminals. 例如,我必须在三个终端上运行这三个命令。 But I need to do those thing using one single file running. 但是我需要使用单个文件运行来做这些事情。

cd /home/xyz/Desktop/project/components/core;
python3 Main.py

aria2c --enable-rpc

cd /home/xyz/Desktop/project/ui;
gulp serve

Try to put your commands in one bash file like those below and run it from terminal. 尝试将命令放在下面的一个bash文件中,然后从终端运行它。

gnome-terminal -e command_1
gnome-terminal -e command_2
gnome-terminal -e command_3

Look here for more details https://askubuntu.com/questions/46627/how-can-i-make-a-script-that-opens-terminal-windows-and-executes-commands-in-the 在这里查看更多详细信息https://askubuntu.com/questions/46627/how-can-i-make-a-script-that-opens-terminal-windows-and-executes-commands-in-the

One of my friends suggested this as an answer and it worked for me.I can run those terminal commands with & operator and then those commands run on background and they will run on the same terminal without any failure.I created a single file using below commands and when I run it, that file prompt to run those commands in same terminal. 我的一个朋友建议这个作为答案,它对我有用。我可以使用&运算符运行这些终端命令,然后这些命令在后台运行,它们将在同一终端上运行而不会出现任何故障。我使用下面的命令创建了一个文件命令,当我运行它时,该文件提示在同一终端上运行这些命令。

!/bin/bash !/斌/庆典

cd /home/xyz/Desktop/project/components/core;python3 main.py & aria2c --enable-rpc & cd /home/kaveesh/Desktop/project/ui;gulp serve & cd / home / xyz / Desktop / project / components / core; python3 main.py&aria2c --enable-rpc&cd / home / kaveesh / Desktop / project / ui / gulp服务&

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

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