Chinaunix首页 | 论坛 | 博客
  • 博客访问: 84606
  • 博文数量: 18
  • 博客积分: 1521
  • 博客等级: 上尉
  • 技术积分: 150
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 18:07
文章分类

全部博文(18)

文章存档

2014年(4)

2011年(1)

2010年(4)

2008年(9)

我的朋友

分类: Python/Ruby

2008-11-27 15:54:15

def getlinux():
        s=os.popen('netstat -n')
        for i in s.readlines():
                l=string.split(i)
                if len(l)<6:
                        pass
                elif len(l)>6:
                        pass
                else:
                        m=string.split(l[4],':')
                        if len(m)<2:
                                pass
                        #else:
                        elif string.atoi(m[-1])>100 and string.atoi(m[-1])<7000:
                                print m[-1],m[-2]
def getwin():
        s=os.popen('netstat -n')
        for i in s.readlines():
                l=string.split(i)
                if len(l)<4:
                        pass
                elif len(l)>4:
                        pass
                else:
                        m=string.split(l[4],':')
                        if len(m)<2:
                                pass
                        elif string.atof(m[1])>100 and string.atof(m[1])<7000:
                                print m[1]
import os,string,re
#print "iiii"
if __name__=='__main__':
        if os.name=='posix':
                getlinux()
        elif os.name=='nt':
                getwin()
阅读(1331) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~