抓取apache2的进程pid:
vi a1.py
#!/usr/bin/python
import os
http = os.popen('netstat -ntpl | grep -w 80','r').readlines()
str1 = ''.join(http)
pid = str1.split()[6].strip('/apache2')
print pid
:wq
抓取apache2的进程pid:
#!/usr/bin/python
import os
http = os.popen('netstat -ntpl | grep -w 80','r').readlines()
str1 = ''.join(http)
pid = str1.split()[6].strip('/apache2')
print pid
:wq