#!/bin/sh
#for exm to test
# ./check.sh 12 36 25 12 453 1 2 3
RETVAL=0
SRRVER_START=1
SRRVER_STOP=2
DNS_STATUS=1
dnsCheck()
{
while test "x`pidof dnsmasq`" != x ; do
echo "check DNS status...................."
sleep 1
break
done
}
globaCheckFun()
{
while true ; do
dnsCheck
echo "check true"
sleep 1
done
}
if [ -n "`ps|grep -v "grep"|grep ppp*`" ]; then
echo "this string is not empty"
else
echo "empty"
fi
#################################################################
tmpdir=/tmp
pppoeId=$tmpdir/ppp0.pid
echo $pppoeId
if [ -f $pppoeId ] ;then
echo "is a file and exist"
else
echo "not a file"
fi
if test "x`pidof "$1"`" != x; then
echo "dnsmasq is running"
else
echo "dnsmasq is stoped"
fi
case "$1" in
dns)
# do your work
echo "$1"
;;
pppoe)
echo "$1"
;;
esac
#################################################################
echo "$@"
echo "$*"
start=`date +%s`
sum=0
for par in "$@"
do
# sum=$(( $par + $sum ))
sum=$[$par + $sum ]
echo $sum
done
endtime=`date +%s`
usedtime=$(( endtime -start ))
echo "usedtime:$usedtime"
echo "parameter num: $#"
for par in "$*"
do
echo $par
done
#
ls sdlfsldkl 2>error
#make BOARD_TYPE=db12x BUILD_TYPE=jffs2 BUILD_CONFIG=_ap123 >uboot_mainline.txt 2>&1
echo `date +%Y-%m-%d-%T`
curretdate=$(date +%Y-%m-%d-%T)
echo $curretdate
#################################################################
if [ $? -eq 0 ]; then
echo "cmd execute ok"
else
echo " cnd executed failed"
fi
line="a;b;c;d;e;f;h;j;k"
oldifs=$IFS
IFS=";"
for itme in $line
do
echo -en "$itme\t"
done
echo
IFS=$oldifs
#################################################################
va=10
if [ $va -eq 11 ]; then
echo "equel ="
elif [ $va -gt 10 ]; then
echo " >"
elif [ $va -lt 10 ]; then
echo " <"
elif [ $va -ge 10 ]; then
echo " >="
elif [ $va -le 10 ]; then
echo " <="
else
echo " other"
fi
#!/bin/sh
if [ "$1" = "" ] ;then
echo " usage./parse_wifi_vap.sh vap/wifiN parse_file "
exit 0
fi
parse_wifi_vap()
{
iwconfigcmd="essid;mode;freq;channel;bit;rate;enc;key;power;nickname;nwid;ap;txpower;sens;retry;rts;frag;modulation;commit"
line=""
start=0;
cmd=""
value=0
temp=""
while read -r line ;do
if [ "$start" = 0 ];then
if [ "$line" = "<"$1 ];then
start=1
continue
fi
elif [ "$start" = 1 ];then
if [ "$line" = $1">" ];then
start=0
break
fi
parameter=`echo $line | cut -d "=" -f 1`
value=`echo $line | cut -d "=" -f 2`
temp=`echo "$iwconfigcmd"|grep "$parameter"`
if [ -n "$temp" ];then
# `iwconfig $1 $parameter $value`
cmd="iwconfig"
else
# `iwpriv $1 $parameter $value`
cmd="iwpriv"
fi
`$cmd $1 $parameter $value`
echo "cmd:\"$cmd $1 $parameter $value \" exeResult:$?"
fi
done < $2
}
WMMFILE=wireless_wmm.conf
# # ath0 AC wmm/acm/aifsn/cwmax/cwmax/noackpolicy/txoplimit value
#iwpriv athN acm AC Mode value
# iwpriv ath0 aifs 0 0 3
# iwpriv ath0 get_aifs 0 0 1
# ath0 get_aifs:3
parse_wmm()
{
start=0
start1=0
tmp=0
value=0
linenum=0;
while read -r line ;do
linenum=$(($linenum+1))
if [ "$start" = 0 ];then
if [ "$line" = "<_$1_" ];then
start=1
continue
fi
elif [ "$start" = 1 ];then
if [ "$line" = "_$1_>" ];then
start=0
break
fi
tempstr=`echo $line | grep "$2"`
if [ "$tempstr" = "<""$2" ] ;then
# echo "start_line:" $1 $2 $line" "
start1=1
fi
if [ "$start1" = 1 ];then
if [ "$tempstr" = "$2"">" ] ;then
start1=0
echo "error:not find $1 $3 in $WMMFILE"
break;
fi
tmp=`echo $line | cut -d "=" -f 1`
tempstr=`echo $3 | cut -d "=" -f 1`
if [ "$tmp" = "$tempstr" ];then
value=`echo $line | cut -d "=" -f 2`
echo "iwpirv $1 $3 "AC_$2" 0 $value"
break;
fi
fi
fi
done < $WMMFILE
# cat $WMMFILE
}
parse_wmm_file()
{
dev=$1
AC=$2
element=
while [ $# -gt 0 ];do
# echo "\$#=$# $@"
element=$3
if [ "$element" = "" ];then
break
else
parse_wmm $dev $AC $element
shift
fi
done
}
#parse_wifi_vap $@
parse_wmm_file $@
echo " $0 vap0 -q BK cwmax=1000"
mkwmmconf()
{
# echo "parameter:$@"
if test -e $WMMFILE;then
tmp=`cat $WMMFILE | grep "##conf"`
if [ "$tmp" = "" ];then
rm -rf $WMMFILE
fi
fi
if ! test -e $WMMFILE ; then
echo "##conf" > $WMMFILE
fi
tmp=`cat $WMMFILE | grep "<_$1_"`
if [ "$tmp" = "" ];then
sed -i '/##end/d' $WMMFILE
echo "----------------------add new :$1---------------------------"
echo "<_$1_" >> $WMMFILE
echo "<BE" >> $WMMFILE
echo "BE>" >> $WMMFILE
echo "<BK" >> $WMMFILE
echo "BK>" >> $WMMFILE
echo "<VI" >> $WMMFILE
echo "VI>" >> $WMMFILE
echo "<VO" >> $WMMFILE
echo "VO>" >> $WMMFILE
echo "_$1_>" >> $WMMFILE
# cat "$WMMFILE"
fi
tmp=`cat $WMMFILE | grep "##end"`
if [ "$tmp" = "" ];then
echo "##end" >> $WMMFILE
fi
#echo "*****************************************************************************************"
# cat $WMMFILE
#echo "*****************************************************************************************"
start=0
start1=0
tmp=0
linenum=0;
while read -r line ;do
linenum=$(($linenum+1))
if [ "$start" = 0 ];then
if [ "$line" = "<_$1_" ];then
start=1
continue
fi
elif [ "$start" = 1 ];then
if [ "$line" = "_$1_>" ];then
start=0
echo "end line:"$line" $1"
break
fi
tempstr=`echo $line | grep "$2"`
if [ "$tempstr" = "<""$2" ] ;then
# echo "start_line:" $1 $2 $line" "
start1=1
fi
if [ "$start1" = 1 ];then
if [ "$tempstr" = "$2"">" ] ;then
start1=0
# echo " end_line:"$line" $1 $3"
# sed -i '/'"$line"'/i\'"$3" $WMMFILE // this cmd will add $3 to $line in all file
sed -i $linenum'i\'"$3" $WMMFILE
echo "insert new element:$1 $3 before line:$linenum to $WMMFILE"
break;
fi
tmp=`echo $line | cut -d "=" -f 1`
tempstr=`echo $3 | cut -d "=" -f 1`
if [ "$tmp" = "$tempstr" ];then
tmp=`echo $line | cut -d "=" -f 2`
tempstr=`echo $3 | cut -d "=" -f 2`
if [ "$tmp" != "$tempstr" ];then
sed -i "$linenum"d $WMMFILE
sed -i $linenum'i\'"$3" $WMMFILE
echo "replace $1 $2: $line to $3 $WMMFILE "
fi
break;
fi
fi
fi
done < $WMMFILE
# cat $WMMFILE
}
工作中使用的脚本: