Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/env python
- #!-*- coding: utf-8 -*-
- from commands import getstatusoutput
- logFile='ipmac.txt'
- nets='192.168.200.1-255'
- command="sudo nmap -sP %s | egrep -i '(Host|MAC)' >> %s" % (nets, logFile)
- status, output = getstatusoutput(command)
- newLines = ''
- if int(status) == 0:
- print 'ok'
- for line in file(logFile).readlines():
- if 'Host ' in line:
- newLines += line.rstrip()+" "
- else:
- newLines += line.strip()+"\n"
- else:
- print "Problema com o comando nmap"
- print output
- FILE = open(logFile, 'w')
- FILE.writelines(newLines)
- FILE.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement