Issue
So I have a "master" python script which should be able to execute different shell scripts and not get stuck in the shell loops.
import socket
import subprocess
UDP_IP = "192.168.50.3"
UDP_PORT = 5005
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
while (True):
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message: %s" % data)
if (data == b'Hello, World!'):
subprocess.call(['sh', './test.sh'])
if (data == b'Hello, Bozo!'):
subprocess.call(['sh', './test1.sh'])
^^The master script
#!/bin/sh
sudo pkill -9 -f led
cd /home/maxi/rpi-rgb-led-matrix/utils
make led-image-viewer
sudo ./led-image-viewer -C tenor.gif --led-rows=64 --led-cols=64 --led-
slowdown-gpio=2
^^The slave script (they all are looking almoast the same.)
I tried with 2 master scripts but I only want to have 1 udp connection so its not great. I didnt find much in the internet, probably because I cant really explain what I need? My idea is to run different gifs on a led matrix and to switch I just kill the led process and restart it. (On a raspberry pi 3b+)
Solution
I used subprocess.call. But if you take subprocess.probe it works without a problem.
Answered By - Ponda Answer Checked By - David Marino (WPSolving Volunteer)