python 獲取主機名 根據端口殺死進程

ip=os.popen("ifconfig eth0|grep 'inet addr'|awk -F ':' '{print $2}'|awk '{print $1}'")
ip=ip.read().strip()
pid=os.popen("netstat -anp|grep 8998 |awk '{print $7}'").read().split('/')[0]
os.popen('kill -9 {0}'.format(int(pid)))
相關文章
相關標籤/搜索