Skip to content

Instantly share code, notes, and snippets.

@jasonrogena
Last active January 13, 2017 12:46
Show Gist options
  • Save jasonrogena/28867d7fe19570000b8eab97d62bdd15 to your computer and use it in GitHub Desktop.
Save jasonrogena/28867d7fe19570000b8eab97d62bdd15 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Enter the serial number for the device you want to switch to WiFi"
read serialNo
ipAddr=`adb -s ${serialNo} shell ifconfig wlan0 | sed -n 's/inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p'`
if [ -z "${ipAddr}" ]; then
ipAddr=`adb -s ${serialNo} shell netcfg | sed -n 's/wlan0[ ]*UP[ ]*\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p'`
fi
echo "IP Addres is "${ipAddr}
adb -s ${serialNo} tcpip 5555
adb connect ${ipAddr}:5555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment