I am using a Linux shell (Ubuntu 20.04) in my Windows 10 Machine. I have a bash script that is supposed to
- Go through a .txt file that contains a list of IPs
- Curl each IP using a site https://ipinfo.io/ for a modified curl output
#!/bin/bash
input="/mnt/d/Docs/BR Resources/iplist.txt"
while IFS= read -r line
do
curl https://ipinfo.io/$line
done < "$input"
The expected output for each IP in the loop is :
{ "ip": "xx.xx.xx.xx",
"hostname": "c0241.brsol.com",
"city": "Ashburn",
"region": "Virginia",
"country": "US",
"loc": "xx.xxxx,xx.xxxx", "org": "BR, Inc.",
"postal": "xxxxx",
"timezone": "America/New_York",
"readme": "https://ipinfo.io/missingauth" }
However, what I get as the output is this error :
curl: (3) URL using bad/illegal format or missing URL
Example excerpt of iplist.txt
36.13.6.167
252.125.137.71
204.50.68.40
136.122.209.112
203.47.25.30
223.96.93.56
64.137.82.169
11.183.223.40
199.169.87.25
119.198.39.119
The issue seems to be that the value of $line is not being passed alongside the rest of the curl command.
How can I fix this to get the modified Curl output for each IP in this .txt file?