I am trying to construct a command which includes a a variable containing IP addresses to a subprocess but the variable is not passed.
iplist
8.8.8.8
1.1.1.1
code
with open('iplist', 'r', encoding="utf-8") as f:
data = f.read()
print(data)
cmd = ['./mmdbinspect', '--db', '/usr/local/var/GeoIP/GeoLite2-City.mmdb', '$data']
result = subprocess.run(cmd, stdout=subprocess.PIPE)
print(result.stdout)
output
8.8.8.8
1.1.1.1
2020/11/01 10:06:13 could not get records from db /usr/local/var/GeoIP/GeoLite2-City.mmdb: $data is not a valid IP address
b''