[Tutor] killing bash, sshd... dangerous?

John washakie at gmail.com
Sun Oct 28 11:58:57 CET 2007


Hello, I've written a little script with the intention of killing all of my
bash, sshd sessions... is this dangerous? How could I make it work so that
it didn't kill the session it was run from (as it is I suppose I have to run
it with nohup):


#!/usr/bin/env python
import os

cmd="ps -u myuser | grep 'bash' > .ps"
os.system(cmd)

pid=[]
fid=open('.ps','r')
for line in fid:
        pid.append(line.split(' ')[0])

for i in pid:
        cmd="""kill -9 %s""" % (i)
        os.system(cmd)


cmd="ps -u myuser | grep 'sshd' > .ps"
os.system(cmd)

pid=[]
fid=open('.ps','r')
for line in fid:
        pid.append(line.split(' ')[0])

for i in pid:
        cmd="""kill -9 %s""" % (i)
        os.system(cmd)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071028/9164d9f2/attachment.htm 


More information about the Tutor mailing list