When I run the below piece of code, Im not getting the expected output. Please correct me..
import socket
import re
NodeName=socket.gethostname()
change_hostname_list=['/etc/hosts1','/etc/sysconfig/network1']
for file in change_hostname_list:
infile=open(file,'r').read()
print NodeName
print file
if re.search('NodeName',file):
print "DOOO"
I need the output "DOOO"
I'm getting the below one,
root@test06> python test.py
test06
/etc/hosts1
test06
/etc/sysconfig/network1
root@test06>
re.search(file, NodeName)?