I have a text file (let's call it test.conf
) that looks something like this:
IP_BASE=10.22.1
IP_NET=${IP_BASE}.0
IP_HOST=${IP_BASE}.1
This file was interpreted by a bash script. The approach was to just simple do
source test.conf
so the variable substition was not a problem. Now we replaced the bash script with a Python script and obviously the substitution does not work anymore. What's the best approach to solve this problem without touching test.conf
?
We could invoke bash
through subprocess
and get the variables this way, but a pure python approach would be preferred.