I'm struck at some point to execute the shell commands from a Python script. Can someone please guide me? Let me explain with an example. Here I'm using two terminals (A and B). In A, one server is running. If there is any change happening in A's terminal's corresponding file. We have to reload the A terminal from the B terminal. How can we do that through a Python script?
I can kill the process that is running in A's terminal but am unable to restart it in A's terminal. Can someone please help me?
Here is the code for identifying the process and killing the process. Please have a look
`rasa_processes = [proc for proc in psutil.process_iter(attrs=['pid', 'name', 'cmdline']) if proc.info['name'] == 'rasa.exe']`
for proc in rasa_processes:
cmdline = proc.info['cmdline']
if ('actions' or '--auto-reload') in cmdline:
os.kill(proc.info['pid'], signal.SIGTERM)