Pages

Thursday, August 30, 2012

Using SL4A bash shell script to connect Linux with Android tablet .

Using Linux with Android OS is very simple.
I install the next two android application: sl4a_r6.apk and PythonForAndroid-r7b1.apk.
Use the PythonForAndroid-r7b1.apk just if you want to write some python scripts.
We can download it from here.
The first: sl4a_r6 it's used to write and run scripts like bash shell, HTML, Java, Python.
With this, the SL4A provides and make APIs available via JSON RPC calls.
The PythonForAndroid-r7b1 allow you to install python modules...
We can read more on this website.
Let's start with one simple bash shell script.
We will make a shell script to test the connection between Linux and Android tablet.
The connection will be through a wireless router that has opened the port through which the communication.
Tablet has Android 4.0.
We use the Linux command NC, see: nc command.
This is the script on the tablet and it will run first.
nc -l -p 7000
See the next image:

Button 1 - run the script
Button 2 - edit the script
Button 3 - save the script
Button 4 - remove the script
Use the next command with your IP on the Linux terminal.
nc xxx.xxx.xxx.xxx 7000
If you type something in your terminal you will see on a tablet.
The input from my linux terminal can be seen in the next image:

Ant this is the output on my tablet.

We can test multiple features of command nc.
I'm just curious if you have some new ideas on this subject.