I am trying to convert wildcard mask to subnet mask. my input text file will be like this 192.168.0.1 0.0.0.255 My expected output : 192.168.0.1 0.255.255.255
I wrote code to convert wildnet mask to netmask. ex: my input file will have
Can someone help me with the coding stuff to acheive this one.
Thanks in advance.
My code for second half:
I wrote code to convert wildnet mask to netmask. ex: my input file will have
Output:0.0.0.15
0.0.15.0
0.0.0.3
my outut will be : Output:255.255.255.240
255.255.240.255
255.255.255.252
The difficult part for me is to integrate the first half (i.e) 192.168.0.1 255.255.255.240Can someone help me with the coding stuff to acheive this one.
Thanks in advance.
My code for second half:
import sys f = open('test.txt','r') for mask in f.readlines(): def wildcard_conversion(mask): wildcard = [] for x in mask.split('.'): component = 255 - int(x) wildcard.append(str(component)) wildcard = '.'.join(wildcard) return wildcard wildcard = wildcard_conversion(mask) ospf = (wildcard) print(ospf) f.close()#end of program