I have a property file "holder.txt" like this which is in key=value
format. Here key is clientId
and value is hostname
.
p10=machineA.abc.host.com
p11=machineB.pqr.host.com
p12=machineC.abc.host.com
p13=machineD.abc.host.com
Now I want to read this file in python and get corresponding clientId
where this python script is running. For example: if python script is running on machineA.abc.host.com
then it should give me p10
as clientId
. Similarly for others.
import socket, ConfigParser
hostname=socket.getfqdn()
print(hostname)
# now basis on "hostname" figure out whats the clientId
# by reading "holder.txt" file
Now I have worked with ConfigParser
but my confusion is how can I get value of key which is clientId
basis on what hostname it is? Can we do this in python?