linux shell脚本

来源:互联网 发布:js cells 编辑:程序博客网 时间:2024/06/06 03:40
#!/bin/sh
#cang
read -p "input run times:" times
echo "times=$times"
suc=0
err=0
tmp=""
while [ "$tmp" == "" ];do
tmp=$(adb shell logcat -d |grep "synccmd: aa 55 1e" |awk -F 'cmd: ' 'END{print $2}')
done
#echo "tmp=$tmp"
fcang=$(echo "$tmp" |awk 'END{split($0,b," ");print b[13];}')
fdong=$(echo "$tmp" |awk 'END{split($0,b," ");print b[14];}')
fbian=$(echo "$tmp" |awk 'END{split($0,b," ");print b[15];}')
ftmp=$(echo "$tmp" |awk 'END{split($0,b," ");print b[20];}')
fzhineng=0
fjiari=0
fsudong=0
fsuleng=0
if [ "$[16#$ftmp&16#02]" == "02" ];then
fzhineng=1
fi
if [ "$[16#$ftmp&16#04]" == "04" ];then
fjiari=1
fi
if [ "$[16#$ftmp&16#08]" == "08" ];then
fsudong=1
fi
if [ "$[16#$ftmp&16#10]" == "10" ];then
fsuleng=1
fi
echo "$fcang $fdong $fbian $fzhineng $fjiari $fsudong $fsuleng"


for loop in {0..10000};do
if [ $loop == $times ];then
echo "break"
break
fi


cang=$[$RANDOM%9]
cangtmp=$[560-$cang*35]
dong=$[$RANDOM%9]
dongtmp=$[560-$dong*35]
bian=$[$RANDOM%24]
biantmp=$[579-$bian*13]
echo "cang=$cang,dong=$dong,bian=$bian"


adb shell input swipe 448 "$cangtmp" 448 "$cangtmp" 10
adb shell input swipe 808 "$dongtmp" 808 "$dongtmp" 10
adb shell input swipe 630 "$biantmp" 630 "$biantmp" 10
sleep 2s
adb shell input swipe 450 150 450 150 10
sleep 2s
adb shell input swipe 450 150 450 150 10
sleep 2s
adb shell input swipe 450 150 450 150 10
sleep 2s
adb shell input swipe 450 150 450 150 10
sleep 2s
adb shell input swipe 450 150 450 150 10


tmp=""
while [ "$tmp" == "" ];do
tmp=$(adb shell logcat -d |grep "synccmd: aa 55 1e" |awk -F 'cmd: ' 'END{print $2}')
done
#echo "tmp=$tmp"
fcang=$(echo "$tmp" |awk 'END{split($0,b," ");print b[13];}')
fdong=$(echo "$tmp" |awk 'END{split($0,b," ");print b[14];}')
fbian=$(echo "$tmp" |awk 'END{split($0,b," ");print b[15];}')
fcang=$[16#$fcang-2]
fdong=$[16#$fdong-2]
fbian=$[16#$fbian-3]
if [ "$cang" == "$fcang" ] && [ "$dong" == "$fdong" ] && [ "$bian" == "$fbian" ];then
suc=$[$suc+1]
#echo "suc=$suc"
else
err=$[$err+1]
#echo "err=$err"
fi
echo "times=$times,suc=$suc,err=$err"
done

echo "times=$times,suc=$suc,err=$err"



简单版本:

#!/bin/sh
read -p "input run times:" times
echo "times=$times"
for loop in {0..10000};do
if [ $loop == $times ];then
echo "break"
break
fi
adb shell input tap 1100 352
sleep 0.5
adb shell input tap 165 727
done



#!/bin/sh
read -p "input run times:" times
echo "times=$times"
for loop in {0..100000};do
if [ $loop == $times ];then
echo "break"
break
fi
stime=$[$RANDOM%1001]*1000  stime表示微秒,这里代表从0-1秒之间取值
echo "stime=$stime"
adb shell input tap 968 96
usleep stime  ——usleep代表微妙
adb shell input tap 73 721
done

0 0