LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 643|回复: 0

一个简单的bash+wget代 理搜索器

[复制链接]
发表于 2010-7-18 10:13:31 | 显示全部楼层 |阅读模式
#/bin/sh
ipfile="ip.txt"
lastipfile="lastip.txt"
port=(808 1080 3128 8080)
web="www.baidu.com"
timeout=3
timetry=1
if [ -z $1 ];then
ip[0]=`cat $lastipfile`
else
ip[0]=$1
fi
tip=${ip[0]}
for (( i=1;i<=4;i++ ));do
ip=${tip/*.}
tip=${tip%.*}
done

echo Enter q/Q for exit
while read -t 1 -n 1 q;
[ "$q" != "q" ] || [ "$q" != "Q" ];do
echo ${ip[0]} > $lastipfile
ping -q -c 1 ${ip[0]}>/dev/null
if [ $? -ne 0 ];then
echo ${ip[0]} is poweroff
else
i=0
while [ -n "${port}" ];do
export http_proxy=${ip[0]}{port}
echo $http_proxy
wget -q -t $timetry -T $timeout -w $timeout $web
if [ $? -eq 0 ];then
echo find $ip{port}
echo $ip{port} >> $ipfile
fi
i=$[i+1]
done
fi
for (( i=1;i<=4;i++ ));do
tip=${ip}
ip=$[tip+1]
if [ ${ip} -lt 255 ];then
break
fi
ip=1
if [ $i -eq 5 ];then
echo finished search
exit
fi
done
ip[0]=${ip[4]}.${ip[3]}.${ip[2]}.${ip[1]}
done
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表