自动化安装卸载apk的脚本

#!/bin/sh

ip="10.85.184.111"
conResult=`adb connect $ip|sed -n '/[Uu]nable/'p`
count=0

while [ \( "$conResult" != "" \) -a \( $count -lt 5 \) ]
do
sleep 1
conResult=`adb connect $ip|sed -n '/[Uu]nable/'p`
echo "try connect again......"
echo $conResult
count=`expr $count + 1`
done

if [ "$conResult" != "" ]
then
echo "connect fail! $conResult"
else
echo "connect to board $ip"

echo "try uninstall......"
#adb shell ls /data/data|sed -n '/test\./p'>uninstallCases.conf
appNum=`adb shell ls /data/data|sed -n '/test\./p'|sed -n '1,$='`
echo $appNum
for appRow in $appNum
do
appName=`adb shell ls /data/data|sed -n '/test\./p'|sed -n '1p'`
#appName=`sed -n "$appRow p" uninstallCases.conf|awk '{printf "%s",$0}'`
echo "@$appName@"
strLen=`echo "$appName"|wc -L`
echo $strLen
str=`echo $appName|cut -c 1-$strLen`
echo "@$str@"
adb uninstall $str
done

echo "try install all cases in dir test_case......"
caseNum=`ls ../test_case/app|sed -n '1,$='`
echo $caseNum
for caseRow in $caseNum
do
caseName=`ls ../test_case/app|sed -n "$caseRow p"`
echo $caseName
#adb shell rm /data/app
adb install ../test_case/app/$caseName
done
fi

exit

你可能感兴趣的:(C++,c,脚本,C#)