Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
shell script to connect android devices over wifi.
#!/bin/bash
echo "This script works with ONLY one Android device connected to system !!!"
echo "Killing adb"
adb kill-server
sleep 2
PORT_NO=6969
CONNETED_DEVICES=$(adb devices | wc -l)
if [ "$CONNETED_DEVICES" -le 2 ]; then
echo "NO Android device connected to your machine via USB."
else
IPADDRESS=$(adb shell ip addr show wlan0 | grep "inet\s" | awk '{print $2}' | awk -F'/' '{print $1}')
if [ -z "$IPADDRESS" ]; then
read -p "NO IP Address found, please check in device setting and Enter ip address: " IPADDRESS
else
echo "device IP is $IPADDRESS, please allow debug on device."
fi
echo "IP ADDRESS : "$IPADDRESS
adb tcpip $PORT_NO
read -p "Disconnect the device and press enter:-"
sleep 2
RESP=$(adb connect $IPADDRESS:$PORT_NO)
echo $RESP
if [ "$RESP" == "connected to $IPADDRESS:$PORT_NO" ]; then
echo "ENJOY wireless debug :)"
else
echo "Something went wrong, Please try again."
fi
fi
@kamleshkarwande

This comment has been minimized.

Copy link
Owner Author

kamleshkarwande commented May 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.