1

I have a list of IPs and want to run a specific curl command on each of them. The command is:

curl --user test:test http://192.168.1.1/security/pkm.html | 
    egrep '@company|config.pkm.password'

And I want to run it for all IPs in IPs.txt:

192.168.1.1
192.168.1.2
192.168.1.3
........1.200
0

1 Answer 1

0

You can simply iterate over each IP in your file:

while read IP; do 
    curl --user test:test http://"$IP"/security/pkm.html | 
        egrep '@company|config.pkm.password'
done < IPs.txt

In your case, where you want all IPs in a range, you could also simply do:

for i in {1..200}; do
    curl --user test:test http://192.168.1."$i"/security/pkm.html | 
        egrep '@company|config.pkm.password'
done
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .