| 1234567891011121314151617181920212223242526272829303132 |
- #!/usr/local/bin/python
- import sys
- import re
- def parse_log(filename):
- hosts = []
- try:
- fh = open(filename, 'r')
- except:
- print "Unable to open logfile"
- sys.exit(1)
- for line in fh:
- matches = re.search('joins \((.+)\)', line)
- if matches:
- hostname = matches.group(1)
- if not hostname in hosts:
- hosts.append(hostname)
- fh.close()
- return hosts
- def main():
- hosts = parse_log(sys.argv[1])
- for host in hosts:
- print host
- if __name__ == "__main__":
- main()
|