A slightly better script.
This script is slightly better in terms of what it does. At the moment it just kills all processes associated with eggdrops.
#!/usr/bin/python
#monitor application
#Author: Shriphani Palakodety
import os
from subprocess import *
process = Popen("ps aux", shell=True, stdout=PIPE)
output = process.communicate()
reqd_output = output[0]
for line in reqd_output.split('n')[1:-1]:
list = line.split()
pid = list[1].split(' ')[0]
for number in pid.split('n'):
print number
pro_ass = Popen(["ps", "-p", number], stdout=PIPE)
outputs = pro_ass.communicate()
a = outputs[0]
if a.find('eggdrop')== True:
os.kill(pid)
print "All banned applications have been killed."
else:
print "No dickface engaging in bs stuff."
Please ignore the last line. It was meant to be there for reasons like testing.
About this entry
You’re currently reading “A slightly better script.,” an entry on Shriphani Palakodety
- Published:
- 08.09.07 / 3am
- Category:
- python
No comments
Jump to comment form | comments rss [?] | trackback uri [?]