-
-
Save jeffypooo/9c358e716d906408a5819151c98ded9b to your computer and use it in GitHub Desktop.
shell script for adb wifi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REGEX_DEV_TCPIP="192\.168\.[0-9].*" | |
REGEX_INET_IP_1="inet (192\.168\.[0-9]\.[0-9]{1,3})" | |
REGEX_INET_IP_2="[0-9\.]+" | |
#List the devices on the screen for your viewing pleasure | |
echo "listing devices..." | |
adb devices | |
echo | |
#Find USB devices only (no emulators, genymotion or connected devices | |
declare -a deviceArray=(`adb devices -l | grep -v emulator | grep -v vbox | grep -v -E "${REGEX_DEV_TCPIP}" | grep " device " | awk '{print $1}'`) | |
echo "found ${#deviceArray[@]} USB device(s)" | |
echo | |
for index in ${!deviceArray[*]} | |
do | |
echo "finding IP address for device ${deviceArray[index]}..." | |
IP_ADDRESS=$(adb -s ${deviceArray[index]} shell ip addr show | grep -E "${REGEX_INET_IP_1}" -o | grep -E "${REGEX_INET_IP_2}" -o) | |
adb -s ${deviceArray[index]} tcpip 5555 | |
sleep 1 | |
adb -s ${deviceArray[index]} connect "$IP_ADDRESS:5555" | |
echo | |
done | |
adb devices -l | |
#exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment