- 论坛徽章:
- 24
|
本帖最后由 chengchow 于 2018-05-14 14:11 编辑
- [root@ansibleserver100 tmp]# cat aa.log
- 192.168.10.192 /27
- 192.168.20.0 /24
- 192.168.30.0 /24
- [root@ansibleserver100 tmp]# cat aa.py
- #!/usr/bin/env python
- import IPy
- import os
- import sys
- IpFile='sys.argv[1]'
- IpList=os.popen('cat '+IpFile).read().replace(' ','').strip('\r\n').split('\n')
- for Ip in IpList :
- print Ip+"<==>"+IPy.IP(Ip).strNormal(3)
-
- [root@ansibleserver100 tmp]# ./aa.py aa.log
- 192.168.10.192/27<==>192.168.10.192-192.168.10.223
- 192.168.20.0/24<==>192.168.20.0-192.168.20.255
- 192.168.30.0/24<==>192.168.30.0-192.168.30.255
复制代码
|
|