Posts tagged “Bash”

Install batches of apps through adb

I made a small script just to test the syntax highlighting plug-in I installed for WordPress. So here it goes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
# Scipt that installs a batch of apk files on an Android device,
# through the adb tool from Android SDK.
adbPath="/home/tomasz/android/android-sdk/tools/adb"
 
if [ $# -ne 1 ]; then
        echo "usage: `basename $0` foldername"
        exit 1
fi
 
for f in $( ls "$1" );
do
        $adbPath install "$f"
done


The script is very simple and installs apk files in a folder through adb (Android Debug Bridge). This of course requires the Android SDK and a some kind of a Linux distribution.

Bash script for pushing files and folders through adb

I have made a script for pushing files and folders through adb to the SDcard of an Android device. This can be used in combination with nautilus for right-clicking on folders to push it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Script for pushing files and folders through adb.
# Can also be used without nautilus.
# Feel free to edit and distribute as much as you want.
 
# if you want dialogs set dialog_enable=1 else dialog_enable=0
dialog_enable=1
 
# Write the entire path to adb here
adbPath="/home/tomasz/AndroidSDK/tools/adb"
 
function dialogs {
        if [ $dialog_enable = 1 ]; then
                if [ -e "/usr/bin/gdialog" ]; then
                        gdialog --title "adb push" --msgbox "$1" 200 200
                elif [ -e "/usr/bin/Xdialog" ]; then
                        Xdialog --title "adb push" --msgbox "$1" 0 0
                else
                        echo "No dialog program present"
                fi
        fi
}
 
if [ $# -ne 1 ]; then    # If arguments not equal 1, complain!
        echo "Usage - $0 file"
        echo "or - $0 directory"
        exit 1
fi
 
if [ -d "$1" ]; then
        $adbPath shell mkdir "/sdcard/`basename "$1"`"  # Create the directory on SDcard
        $adbPath push "$1" "/sdcard/`basename "$1"`"    # Push files in the folder to folder on SDcard
        dialogs "Folder $1 was pushed"
elif [ -e "$1" ]; then
        $adbPath push "$1" /sdcard/    # Push single file to SDcard
        dialogs "$1 was pushed"
else
        echo "Gurumeditation!"    # Oops!
fi


Download the script by using this link: http://ostebaronen.dk/android/adbpush.sh

In order to have it in your right-click menu in Nautilus place the script in: ~/.gnome2/nautilus-scripts/ and run chmod u+x ~/.gnome2/nautilus-scripts/. Now you should see the script in your right click menu under scripts in Nautilus.