Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
import subprocess
import re
import optparse
ifconfig_result = subprocess.check_output(["ifconfig", options.interface])
print(ifconfig_result)
mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result)
print(mac_address_search_result.group(0))


What I have tried:

tried converting double quoted string to single quoted
Posted
Updated 6-May-20 10:45am
Comments
ZurdoDev 6-May-20 10:18am    
Which line of code gives that error?
ZurdoDev 6-May-20 10:19am    
The error likely is saying you can't use search on a byte. You can also use search on strings.

1 solution

Try
Python
mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result.decode('utf-8'))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900