简体   繁体   English

如何通过单个bash脚本在不同的终端(每个具有不同的PID)中运行不同的python文件?

[英]How to run different python files in different terminals (each having different PIDs) from a single bash script?

I have 3 python files stored in different folders. 我有3个python文件存储在不同的文件夹中。 I need these files to run in different terminals. 我需要这些文件在不同的终端上运行。 I have also tried the solution given here but this is not what I am trying to achieve. 我也尝试过这里给出的解决方案但这不是我要达到的目的。 This is my code so far: 到目前为止,这是我的代码:

RPI_GATEWAY_LAUNCHER.py RPI_GATEWAY_LAUNCHER.py

#!/bin/sh

###### STARTING UP NRF MODULE #####
sleep 2
cd Desktop/RPI_GATEWAY/NRF24L01
python NRF_MQTT.py
sleep 5
###################################

#### STARTING UP TEST MODULE 1 ####
cd Desktop/RPI_GATEWAY/TEST
python TEST_PUB_1.py
sleep 2
###################################

#### STARTING UP TEST MODULE 2 ####
cd Desktop/RPI_GATEWAY/TEST
python TEST_PUB_2.py
sleep 2
###################################

you can try with: 您可以尝试:

#!/bin/sh

###### STARTING UP NRF MODULE #####
sleep 2
pushd Desktop/RPI_GATEWAY/NRF24L01
terminal -e python NRF_MQTT.py
pwd
sleep 5
###################################

#### STARTING UP TEST MODULE 1 ####
pushd Desktop/RPI_GATEWAY/TEST
terminal -e python TEST_PUB_1.py
sleep 2
pwd
###################################

#### STARTING UP TEST MODULE 2 ####
pushd Desktop/RPI_GATEWAY/TEST
terminal -e python TEST_PUB_2.py
sleep 2
pwd
###################################

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

相关问题 (多线程-Python)如何创建一个运行两个脚本的脚本,我通常从两个不同的终端运行这些脚本? - (Multithreading-Python) How I can create a script that run two scripts which I usually run from two different terminals? 在不同终端运行多个 python 脚本 - Run multiple python scripts in different terminals 如何运行python脚本作为不同文件的循环? - How to run a python script as a loop for different files? 如何从bash中的python脚本的一组不同的输入文件中输出多个文件 - how to output multiple files from a set of different input files for a python script in bash 如何使用bash脚本从其他目录运行代码 - How do I run code from a different directory with a bash script 从一个python文件在不同的终端/控制台中运行多个python文件 - Running multiple python files in different terminals/consoles from one python file 从python脚本运行它的不同目录中的bash脚本转储文件 - dump files from bash script in different directory from where python script ran it 如何从具有不同解释器版本的python运行python脚本? - How to run python script from python with different interpreter version? 如何 select 来自不同目录的每 20 个文件,Python? - How to select each 20 files from different directories, Python? 如何从不同的脚本在 python 中运行 3 个函数? - How can I run 3 functions in python from a different script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM