Balayage plage IP en python
Bonjour,
je suis débutant en Python et je veux simplement connaitre l'ensemble des @IPS correspondant à IP/netmask (afin de les pinger)
Le code ci-dessous marche
Code:
1 2 3 4 5
| #!/usr/bin/python
from netaddr import *
import pprint
for ip in IPNetwork('192.0.2.0/23'):
print '%s' % ip |
Par contre
Code:
1 2 3 4 5
|
IP = "192.0.2.0"
MASK = 23
for ip in IPNetwork('IP/MASK'):
print '%s' % ip |
me donne
File "./range.py", line 13, in <module>
for ip in IPNetwork('IP/MASK'):
File "/usr/lib/pymodules/python2.6/netaddr/ip/__init__.py", line 693, in __init__
self.value = prefix
File "/usr/lib/pymodules/python2.6/netaddr/ip/__init__.py", line 722, in _set_value
% value)
Donc d'une certaine façon je ne sais pas passer des arguments à IPNetwork
Merci pour votre aide