Android Remote Control Setup

Control your Android devices while running scripts on your computer!

Wonder can be done with ASE and an android device along with scripting languages like Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell.

Would it not be wonderful to run code on your box and the same being reflected on your android devices ?

The same is achieved with help of Scripting Layer for Android's remote control.

Before one uses the script make sure that you have a GNU/Linux box with sudo privileges and an Android device with ASE installed on it.

The below is the simple setup script I wrote to make the process easier.

# License : GPLv3
# Author  : <[email protected]>
# Site    :
# Purpose : Remote control android setup process

function check_sudo(){
    # Check if the user has sudo privilages
    sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }

function setup(){

    # Check if the use have sudo privileges, if fine, move on.

    # Get the latest version of android SDK.
    echo -e "Download and extracting the latest version of android sdk to /opt dir\n"
        cd /opt
        curl -s $(curl -s "" | grep -o -E 'href="([^"#]+).tgz"' | cut -d'"' -f2) | tar xz && echo "Completed download of sdk" || echo "Unable to download the SDK!"
        # exit has the download did not happen
        exit 1
        cd android-sdk-linux
        echo -e "\nUpdating SDK and fetching tools..."
        tools/android update sdk -o --no-ui \
        --filter platform,platform-tool,tool,system-image
        echo -e "\nDone updating!"
        echo -e "\nAppending PATH to have android sdk tools"
        echo "PATH=\"\${PATH}:~/android-sdk-linux/tools\"" >> ~/.bashrc
        # Source ~/.bahrc so that the path is updated
        source ~/.bashrc

        # Start server
        sudo ./adb kill-server && sudo ./adb start-server

        echo -e "\n Almost done, now start a public/private server on your phone. Note : If private server phone must be connected via USB."
        # As of now, not worrying about validating IP, cause the users who will be using this script will be sane enough to give the right IP :)
        read -p "Enter IP:PORT of the server which is running on your phone" FIP
        # Extract IP and PORT from the value read above.
        local IP   = $( echo FIP | cut -f1 -d":")
        local PORT = $( echo FIP | cut -f2 -d":")
        # Port forwarding
        sudo ./adb forward tcp:9999 tcp:$PORT
        # Export host and port  
        [[ ! -z $IP ]] && export AP_HOST = $IP
        [[ ! -z $PORT ]] && export AP_PORT = $PORT
        # Get the site_package location
        site_package_path = $(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
        # Get SLA4's
        echo -e "\n Getting SLA4's to $site_package_path"
        curl -s "" > $site_package_path/

echo -e "Starting the setup...\n"
echo -e "Done with the setup! import android and explore!"

To setup your machine just do the below :

sudo bash < <( curl )

Now you can control your Android device from your terminal, using ASE API

For example, the below code would sent a toast to your Android device from your terminal :

$ python
Python 2.6
Type "help", "copyright", "credits" or "license" for more information.
>>> import android  # The SL4A module should be on your sys.path.
>>> droid = android.Android()  # Or android.Android(('Public IP', PORT)) 
>>> droid.makeToast("Hello from my GNU!")

< /br>

FORK it from

Enjoy the power of free and open software!

Share this