I want to call 2 python scripts using tcp Conditionally via another main script. So, when my data sent to the main script is "YES", the first script executed and when data = "No", the second script executed! the problem is that when the data sent "YES" the first script runs, but when the data sent "No", the second one does not execute, so I realized that I have to add a condition to kill the first one in order to run the second and vice versa, so how can I do it? Help me, please!
#main script
#!/usr/bin/env python
import os
import socket
backlog = 1
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('192.168.43.95', 12345))
s.listen(backlog)
try:
print ("is waiting")
client, address = s.accept()
while True:
data = client.recv(size)
if data == "YES \n":
os.system('python script1.py')
elif data == "No \n":
os.system('python script2.py')
except:
print("closing socket")
client.close()
s.close()