On Nov 18, 12:25 pm, Jean-Michel Pichavant <[email protected]>
wrote:
> Hi python fellows,
>
> I'm currently inspecting my Linux process list, trying to parse it in
> order to get one particular process (and kill it).
> I ran into an annoying issue:
> The stdout display is somehow truncated (maybe a terminal length issue,
> I don't know), breaking my parsing.
Below is the script I use to automatically kill firefox if it is not
behaving, maybe you are looking for something similar.
HTH,
Bas
#!/usr/bin/env python
import commands, os
lines = os.popen('ps ax|grep firefox').readlines()
lines = [line for line in lines if 'grep' not in line]
print lines[0]
pid = int(lines[0][:5])
print 'Found pid: %d' %pid
os.system('kill -9 %d' %pid)
--
http://mail.python.org/mailman/listinfo/python-list