Chaemelion's Blog

My cyber-security thoughts, hacking projects, and experiments.


Push to Android Context Menu

Posted by Chaemelion on February 14, 2013 at 1:40 PM

Ever have .apk's or files on your computer that need to be pushed to your android phone? Believe me, I know what a hassle it can be to transfer just a single file, especially when it's the last thing you need to do before hitting the hay at 3 am... Anyhow, now that I'm more or less a strict linux user, I'm porting my windows scripts to make my life easier. I installed ADB (the Android Debugger Bridge for those unaware) to my /usr/bin directory and wrote this little script to transfer files to any phone on my wireless network that has ADB listening over TCP/IP. 

I use ADB Konnect on my rooted android to set up the ADB listener, and simply run this script passing it the path to the file I wish to transfer. It uses zenity to query the user for the IP and port that ADB Konnect displays, as well as the destination on the device (/sdcard/ by default), and pushes the file.

I use Nautilus Actions Configuration to add a right-click context menu to my file browser labeled "Push to Android" and have it invoke the script, passing it the currently selected file in browser. That simple. Just remember to disable ADB on your phone when you're finished...

Hope someone finds this useful. I'll link to the requirements below.

IP=$(zenity --entry --text "Android IP: Port" --entry-text ""); 
RESULT=$(adb connect $IP);
if [[ $RESULT = *connected* ]]
	DEST=$(zenity --entry --text "Destination" --entry-text "/sdcard/");
	RESULT=$(adb push $1 $DEST 2>&1);
	zenity --info --text "$RESULT";
	zenity --error --text "ADB could not establish connection!";

ADB Konnect


Categories: None

Post a Comment


Oops, you forgot something.


The words you entered did not match the given text. Please try again.

Already a member? Sign In


Reply Jamossweve
6:08 AM on July 10, 2021 
This is nicely expressed! !
Reply Jamossweve
8:39 PM on July 10, 2021 
This is nicely put. !