I have to write python code to:
- Read text file as input (separated by tabs and usually two columns)
- Check the httpd.conf file for that parameter and its value
For example, I have a text file like this:
KeepAlive on
Listen 80
TCP On
and a normal httpd.conf
file too.
I want to check and compare each line fields and if the config was correct, then print keepalive is ok
for example.
I wrote this:
d = []
with open("config.txt") as CFGF:
for line in CFGF:
key, val = line.split()
c = key, val
d.extend(c)
with open("httpd.conf") as f:
j = 0
for i in d:
for line in f:
ls = line.strip()
if d[j] in line:
if d[j + 1] in line:
print(line.rsplit())
j += 1