I am starting in Python and hope you can help me solve this problem.
I have a list of mac addresses written in a file. I need to get a list of mac addresses on the network, compare them with the addresses from the file, and then type in stdout the addresses from the file that are not found in the address list from the network.
And at the end, update the file with these addresses.
Now I managed to read the file that I give as an argument:
import sys
with open(sys.argv[1], 'r') as my_file:
lines = my_file.read()
my_list = lines.splitlines()
I am trying to read mac addresses by running process arp from python:
import subprocess
addresses = subprocess.check_output(['arp', '-a'])
But with this code, I get the following:
Internet Address Physical Address Type
156.178.1.1 5h-c9-6f-78-g9-91 dynamic
156.178.1.255 ff-ff-ff-ff-ff-ff static
167.0.0.11 05-00-9b-00-00-10 static
167.0.0.123 05-00-9b-00-00-ad static
.....
How can I filter here to get only mac address list?
Or I can check two lists, like this, to find out if there is a MAC address from a file on the network and not print it?