My get_current_mac function:
def get_current_mac(interface):
ifconfig_result = subprocess.check_output(["ifconfig", interface])
mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)
if mac_address_search_result:
return mac_address_search_result.group(0)
else:
print("[-] Could not read MAC address.")
I am then wanting to print the result to the screen:
options = get_arguments()
current_mac = get_current_mac(options.interface)
print("Current MAC address is: " + str(current_mac))
The entire error is:
Traceback (most recent call last):
File "./MAC_changer.py", line 38, in <module>
current_mac = get_current_mac(options.interface)
File "./MAC_changer.py", line 30, in get_current_mac
mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)
File "/usr/lib/python3.7/re.py", line 183, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
line 38 is: options = get_arguments()
line 30 is: mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)