linux shell脚本

#!/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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值