Last change
on this file since 3 was
3,
checked in by sscpbas, 21 years ago
|
Added command line option to specifiy where the pxe config directory resides.
This is for client ans server side.
Added some info about the package such as a READMEE, AUTHORS and LICENSE.SARA
file.
|
File size:
923 bytes
|
Rev | Line | |
---|
[3] | 1 | #! /usr/bin/env python |
---|
| 2 | ''' |
---|
| 3 | hexls.py - Lists directory contents, but converts the hexadecimal IP numbers |
---|
| 4 | to dotted decimal notation (so you can at least see what you're doing..!!) |
---|
| 5 | |
---|
| 6 | Author: Walter de Jong <walter@sara.nl> |
---|
| 7 | Date: January 2002 |
---|
| 8 | |
---|
| 9 | CVS info |
---|
| 10 | $Date: 2002/02/19 09:38:10 $ |
---|
| 11 | $Revision: 1.1 $ |
---|
| 12 | ''' |
---|
| 13 | |
---|
| 14 | import os |
---|
| 15 | import string |
---|
| 16 | import re |
---|
| 17 | |
---|
| 18 | def hexls(path): |
---|
| 19 | '''list directory, convert hexadecimal to dotted decimal''' |
---|
| 20 | |
---|
| 21 | regexp = re.compile('[' + string.hexdigits + ']+') |
---|
| 22 | for f in os.listdir(path): |
---|
| 23 | if regexp.match(f) and len(f) == 8: |
---|
| 24 | digit1 = string.atoi(f[:2], 16) |
---|
| 25 | digit2 = string.atoi(f[2:4], 16) |
---|
| 26 | digit3 = string.atoi(f[4:6], 16) |
---|
| 27 | digit4 = string.atoi(f[6:], 16) |
---|
| 28 | |
---|
| 29 | print '%s => %d.%d.%d.%d' % (f, digit1, digit2, digit3, digit4) |
---|
| 30 | else: |
---|
| 31 | if f[0] != '.': |
---|
| 32 | print f |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | if __name__ == '__main__': |
---|
| 36 | import sys |
---|
| 37 | |
---|
| 38 | if len(sys.argv) > 1: |
---|
| 39 | for dir in sys.argv[1:]: |
---|
| 40 | hexls(dir) |
---|
| 41 | else: |
---|
| 42 | hexls('.') |
---|
| 43 | |
---|
| 44 | # EOB |
---|
| 45 | |
---|
Note: See
TracBrowser
for help on using the repository browser.