I am trying to construct the command which includes the variable containing IP addresses to the 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''