This is the code:
import os
import re
import subprocess
current_setting = list()
with open('/etc/init/control-alt-delete.conf' ,'r')as fp:
for line in fp:
if not line.startswith('#'):
current_setting.append(line.strip())
current_setting.remove('')
print current_setting
desired_setting = list()
with open('ctl_alt_del', 'r') as f:
for line in f:
desired_setting.append(line.strip())
print desired_setting
if set(current_setting) == set(desired_setting):
print 'The file has to be modified'
I am getting output as:
['start on control-alt-delete', '', 'exec /sbin/shutdown -r now "Control-Alt-Delete pressed"']
['start on control-alt-delete', 'exec /sbin/shutdown -r now "Control-Alt-Delete pressed"']
The two lists are identical except the white space between two entries of the first list. Because of that, the comparison is giving false value. How to remove that white space? Please help. Thank you in advance.