Last active
April 24, 2023 21:11
-
-
Save kamleshkarwande/fe3edd5d13757fcedd457ac4c0953a97 to your computer and use it in GitHub Desktop.
shell script to connect android devices over wifi.
This file contains hidden or 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
disconnect script is at this link
https://gist.github.com/kamleshkarwande/92a2421ee3f1881ed10d59949b6a4e4d