Created
October 7, 2012 14:48
-
-
Save is/3848577 to your computer and use it in GitHub Desktop.
Increase bind zone serial by python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, sys | |
def fresh_serial(fn): | |
fin = file(fn, 'r') | |
lines = fin.readlines() | |
fin.close() | |
ols = [] | |
for line in lines: | |
if line.find('__ZONE_SERIAL__') >= 0: | |
curstr = line.split()[0] | |
curo = line.find(curstr) | |
newstr = '%-8d' % (int(curstr) + 1) | |
oline = line[:curo] + newstr + line[curo + 8:] | |
line = oline | |
print 'zone %s: serial %s -> %d' % (fn, curstr, int(curstr) + 1) | |
ols.append(line) | |
fout = file(fn, 'w') | |
fout.write(''.join(ols)) | |
fout.close() | |
if __name__ == '__main__': | |
fresh_serial(sys.argv[1]) | |
# vim:ts=2 sts=2 ai |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment