I am trying to check if the process is running by giving the process name and if there i am trying to kill and i want to restart the process again. So inside subprocess.call i give the path for the file i need to call. My question here is inside the (/examples) i have many executable files like example1.py,exmaple2.py etc. When i run this script now it shows process found and then kills it. I need to know how i can pass the particular example that i want to call again from the terminal(like i want to execute example1.py and later another script)
for process in psutil.process_iter(): if (process.name().startswith('python')) and ("new_scene" in process.cmdline()[1]): print('Process found') process.kill() time.sleep(3) subprocess.call('python /Desktop/Test/Script/new/new_scene.py --run /Desktop/Test/Script/new/scenario/examples', shell=True) break else: print('Process not found')