Let's say I just want to search a dhcpd file for host entries, their IP and MAC, and print them in one line. Here, I want some help with a python script. I can able to find the IP address and hostname but I don't know how to get the variables out of the if statement to put it in one line. Look at the below code and give me some suggestions guys?
#check for arguments
if len(sys.argv) > 1:
print "usage: no arguments required"
dhcp_file = open("/etc/dhcp/dhcpd.conf","r")
for line in dhcp_file:
split = re.split(r'\s+', line)
if re.search(r'\bhardware ethernet\b',line):
ip = re.split(r'\s+',line)