I'm trying to get a substring from a string, it has to be specific though,
if you use this function and print it you'd get a long string with all the currently unresponsive processes and their infos, I need the PID from a specific process.
r = os.popen('tasklist /FI "STATUS eq Not Responding"').read().strip()
print r
example if chrome.exe is not responding it would be in the list and I would like to get the PID associated with it. I tried split()
and pop()
to single out what I needed without success.
Edit :
I have 10+ processes that all share the same application name.
It's necessary for me to use PID and that it belongs to the correct application. I don't want my script to kill everything either.
So in short I need to find the PID that is on the same row as the specified 'process_name' and then only keep that 'PID'
Hope that makes sense.