Skip to content

Instantly share code, notes, and snippets.

@YUChoe
Created January 30, 2015 02:58
Show Gist options
  • Save YUChoe/c9e865c5a292a2305572 to your computer and use it in GitHub Desktop.
Save YUChoe/c9e865c5a292a2305572 to your computer and use it in GitHub Desktop.
fron list.txt to ccd
#!/usr/bin/python
def ipaddone(i) :
l = i.split(".")
brd30 = [3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,211,215,219,223,227,231,235,239,243,247,251,255]
if int(l[3])+1 in brd30 :
return "%s.%s.%s.%d" % (l[0],l[1],l[2],int(l[3])-1)
return "%s.%s.%s.%d" % (l[0],l[1],l[2],int(l[3])+1)
fp = open ("list.txt")
# test test06 10.17.1.21 2015-1-8 21:30:46 test06
for l in fp.readlines():
l = l[:-1]
if l == "" : continue
sl = l.split()
if len(sl) < 4 : continue
print ("%s ifconfig-push %s %s" % (sl[1], sl[2], ipaddone(sl[2])))
ffp = open(sl[1], 'w')
ffp.write("ifconfig-push %s %s" % (sl[2], ipaddone(sl[2])))
ffp.close()
fp.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment