【发布时间】:2014-06-08 05:00:05
【问题描述】:
我正在通过下载一些东西来测试一些 IP:Port 代理,以查看其中一些代理是否有效。我的工作脚本是
#!/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
wget 成功的典型输出是
--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
失败时的输出是
--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.
现在的问题是,grep 似乎不起作用!它在 notok.txt 文件中输出所有 IP 地址。天气 wget 成功与否它输出 notok.txt 中的所有地址。我该如何解决这个问题?
【问题讨论】:
标签: bash ubuntu proxy grep wget