#!/bin/bash
#`rm -rf ~/.ssh/known_hosts`
#注意这里更改文件名
net_file=./iplist.txt
mun_sum=`cat $net_file|wc -l`
rm -rf ./inst_ping_failed.txt
rm -rf ./iaas_upconnect_fialed.txt

for mun in `seq 1 $mun_sum`
    do
		card_net=`sed -n "$mun"p $net_file`

               {
                        adb_connect_result=$(timeout 3 adb connect $card_net 2>&1)
			if [[ $adb_connect_result == *"connected to"* ]]; then
		        	version_check=$(timeout 2 adb -s $card_net shell ping -c 1 -W 1 www.baidu.com)
				if [[ $version_check == *"1 packets transmitted, 1 received"* ]]; then
						echo "$card_net 通信正常"
					else
						echo "$card_net 通信失败" >>./inst_ping_failed.txt
					fi
				adb disconnect $card_net
			else
				echo "$card_net" >>./iaas_upconnect_fialed.txt
				adb disconnect $card_net
			fi

                        }
    done

