教育网找代理的脚本(从oneleaf那个改的)

sh/bash/dash/ksh/zsh等Shell脚本
回复
moonchild
帖子: 116
注册时间: 2005-12-25 20:44
送出感谢: 0
接收感谢: 0

教育网找代理的脚本(从oneleaf那个改的)

#1

帖子 moonchild » 2006-05-22 13:24

原帖在此:
viewtopic.php?t=1509&postdays=0&postorder=asc&start=0

为了符合自己的要求,修改了一下。(我是新手,请不要笑我)

我用这个配合firefox的xyzproxy扩展使用。(那个扩展可以从文本文件导入代理)

代码: 全选

#!/bin/bash
#Copyright (c) 2005 ubuntu.org.cn
#License: GPLv2

wget -O proxy.html -q http://info.hustonline.net/index/proxyshow.aspx

PROXYS=`cat proxy.html |grep '<b>' | nawk '{print $1}' | cut -c4- |cut -d\< -f 1 | sort`;

rm proxy.html


OLDPROXY=$http_proxy;  # save the old proxy

WGET="wget --cache=off -q -T 35 -t 1 -w 0 -O /dev/null www.thecure.com";
#  -q : quiet   T=Timeout  t=try    w=wait second

for proxy in $PROXYS ; do
   echo "Testing http://$proxy..."
   export http_proxy="http://$proxy"
   TEMPTIME=`/usr/bin/time -o proxy-timer.txt -f %e $WGET`;

   if [ "$?" = 0 ] ; then
       TEMPTIME=`cat proxy-timer.txt`;
       echo -n $proxy  >> proxy-test.txt
       echo  \#$TEMPTIME >> proxy-test.txt
       fi
done

rm proxy-timer.txt

cat proxy-test.txt | sort -t# -n +1 > proxy-result.txt
# -t : define seprerator    -n : sort as number   +1 : sort field 1 (count from 0)

rm proxy-test.txt

export http_proxy=$OLDPROXY
exit 0

回复

回到 “Shell脚本”