Sending Shell Commands to Connected ADB Devices (Amazon FireTV)

Last Updated on

Like many other individuals you may find yourself in the position of having multiple amazon devices on your network. In my situation, there are two Amazon FireTV units on my home network, different generations. Typically these units are extremely stable and require no user intervention or maintenance. Having said that, on occasion (rarely) it becomes necessary to power cycle each one individually usually due to a network configuration change or an update. I created the following script to loop through the Amazon devices on my network and reboot them.

In order to connect to Amazon or similar android devices over the network, you will need to install ADB.

This script first connects to my two FireTV units, then executes a loop which sends a command to all ADB connected devices. If you have more devices connected in the first portion of the script, the loop will execute the specified command on each device sequentially.

adb kill-server
adb start-server
adb connect amazon2.nuuk.local
adb connect amazon2.nuuk.local
sleep 2
db devices | awk 'NR>1{print $1}' | xargs -n1 -I% adb -s % shell reboot

Having configured DDNS on my network, i specified DNS alias’ – otherwise your connect commands DNS will have the device serial number in the hostname similar to these:

adb connect amazon-172d52eec.nuuk.local
adb connect amazon-b6e513e72.nuuk.local

About the author

Lima is the visual nautical indicator for "stop instantly."

Leave a Reply