fo=open("haproxyfile.txt","r")
users=[]
for lines in fo.readlines():
if 'user' and 'password' in lines:
items=lines.split() #converts to list"""
users.append(items[1]) #append the second item that is the username"""
print users
The content of haproxyfile.txt is below
ssl-default-bind-ciphers EECDH+EDSA+ACM:CDH+aRSA+AEdfGCM:EECDH+ECDSA+SHA384:EEC+
ESA+SHA:EDH+aRSA+SHA384:EECDH+aRSA+SHA256:EDH:AES128-GCM-SHA256:AES128-SHA256:AES128-S
HA:EDH+SA:AES256-GCM-SHA384:AES-SHA256:AES256-SHA:!RC4:!aNULL:!eNULL:!LOW:!3D:!MD5:!EXP:
!PSK:!SRP:!DSS
# Users
userlist IntacctAdmins
group admins users aasghar,achouchoulas,bwright,calla,gspiliotis,haris,pdam
user aasghar password $1$CFdTKLSRSbQME/
user achouchoulas password $1$uLy//uPCaVSNhfFG/
user bwright password $1$q3Fk$kmqM.J531
user calla password $1$f%g23a44$Bl.1fPj/
user gspiliotis password $1$d/2OI.TQOiV1
user haris password $1$mwQ$uG/1mUjE0
user pdam password $1t24Z$K4FUH/
What I need to parse from the content
The line after having the words groups are the lines where my user names are located. They are the single words after user keyword.I have fetched it using the method above.Is there any better way to fetch it?
group admins users
line by commas. :p \$\endgroup\$