Python Forum
python script to get wildcard mask output in the following format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python script to get wildcard mask output in the following format
#1
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
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.240

Can 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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,196 Jun-29-2023, 11:57 AM
Last Post: gologica
  Reading Excel file and use a wildcard in file name and sheet name randolphoralph 6 7,049 Jan-13-2022, 10:20 PM
Last Post: randolphoralph
  How do I mask Hex value wiht 0xFF? korenron 2 4,457 Nov-23-2021, 09:13 AM
Last Post: Gribouillis
  Real-Time output of server script on a client script. throwaway34 2 2,048 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  pymongo wildcard query issue MikeAW2010 2 4,259 Jul-06-2021, 09:25 AM
Last Post: swag
  format the output from a nested dictionary. nostradamus64 9 4,530 May-03-2021, 04:45 PM
Last Post: nostradamus64
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 2,340 Feb-05-2021, 04:37 PM
Last Post: nilamo
  Using boolean mask in Numpy for 3D IlikePi 0 1,512 Nov-14-2020, 10:08 PM
Last Post: IlikePi
  Import output from python script to another varietyjones 1 1,901 Oct-12-2020, 09:07 PM
Last Post: bowlofred
  JupyterLab Dictionary Content Output Format Ourkid123uk 0 1,308 Sep-04-2020, 02:18 PM
Last Post: Ourkid123uk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020