我可以使用bash脚本运行多个Python输入吗?

2024-04-24 06:29:34 发布

您现在位置:Python中文网/ 问答频道 /正文

许多人认为,这段代码应该同时运行。所有这一切只是运行文件,但它总是留下一个随机文件等待接收输入。你知道吗

#!/bin/bash

echo "SCRIPT START"
echo "user = ${USER}"
cd
service nginx start
cd /var/app/scripts
python script_reset.py -1
python script_print_ticket.py 18 &
python script_reset.py 23 &
python script_balcony.py 5 1 &
python script_balcony.py 6 2 &
python script_balcony.py 13 3 &
python script_balcony.py 19 4 &
python script_balcony.py 26 5 &

在每个python文件中,我都使用GPIO输入(来自Raspberry Pi的pin),但我认为这是不相关的,但不管怎样。你知道吗

while True:
    #Read button input status
    btn_input_state = GPIO.input(button)

谢谢你

卢卡斯


Tags: 文件代码pyechobashinputgpiobin
1条回答
网友
1楼 · 发布于 2024-04-24 06:29:34

为什么不在一个.py中运行这些?
例如:

import script_reset, script_print_ticket, script_balcony
if __name__ == '__main__':
    script_reset.main(-1)
    while True:
        script_print_ticket.main(18)
        script_reset.main(23)
        for i, p in enumerate([5, 6, 13, 19, 26], 1):
            script_balcony.main(p,i)
        timer.sleep(1)

相关问题 更多 >