Open shakhboz997 opened 2 years ago
Hi,
Without seeing the whole code I think the issue is you are passing in a byte array ( variable ifconfig_result) This needs to be a string for re.search to work, then when you get the result mac_address_search_result you will need to get the nth index of it to return a string as it is an object still. so to review convert ifconfig_result to string use mac_address_search_result[0] to pass the resulting string of "08:00:27:50:4c:14" in your above example
Hope this helps resolve your issue, if it does resolve your issue please mark this issue as resolved
can you help, where i made a mistake.
b'eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500\n inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255\n inet6 fe80::a00:27ff:fe50:4c14 prefixlen 64 scopeid 0x20\n ether 08:00:27:50:4c:14 txqueuelen 1000 (Ethernet)\n RX packets 8780 bytes 10354741 (9.8 MiB)\n RX errors 0 dropped 0 overruns 0 frame 0\n TX packets 6205 bytes 1055091 (1.0 MiB)\n TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0\n\n' Traceback (most recent call last): File "/root/PycharmProjects/mac_changer/mac_changer.py", line 34, in
current_mac = get_current_mac(options.interface)
File "/root/PycharmProjects/mac_changer/mac_changer.py", line 27, 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.9/re.py", line 201, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object