I am testing some IP:Port proxy by downloading something to see if some of these proxy valid or not. My working script is
#!/bin/bash for pro in $(cat testing.txt);do wget -e use_proxy=yes -e http_proxy=$pro --tries=1 --timeout=15 http://something.com/download.zip if grep --quiet "200 OK"; then echo $pro >> ok.txt else echo $pro >>notok.txt fi done
Typical output on success by wget is
--2014-06-08 10:45:31-- http://something.com/download.zip Connecting to 186.215.168.66:3128... connected. Proxy request sent, awaiting response... 200 OK Length: 30688 (30K) [application/zip] Saving to: `download.zip' 100%[======================================>] 30,688 7.13K/s in 4.2s
and output on failure is
--2014-06-08 10:45:44-- http://something.com/download.zip Connecting to 200.68.9.92:8080... connected. Proxy request sent, awaiting response... Read error (Connection timed out) in headers. Giving up.
now problem is , grep seems not working! It output all ip address in notok.txt file. Weather wget success or not it output all address in notok.txt . How can I solve this?