〖Android〗存在多个Android设备时,使用Shell脚本选择一个Android设备

Shell脚本:

#!/bin/bash
devices=( $(adb devices|grep device$|awk '{print $1}'|xargs echo) )

case ${#devices[@]} in
    0 )
        echo "can't found a android device!"
        ;;
    1 )
        serial=$devices
        ;;
    * )
        select serial in ${devices[@]}; do
            break;
        done
        ;;
esac

if [[ -z $serial ]]; then
    echo "Not select a android device, exit not"
    exit 1
fi

adb -s $serial shell echo OK

 

posted @ 2015-04-22 16:41  scue  阅读(390)  评论(0编辑  收藏  举报