joi, 30 august 2012

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

Using Linux with Android OS is very simple.

I install 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 cand download it from here.

The first : sl4a_r6 it's use 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.

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 7000

If you type something in your terminal you will see on tablet.

The input from my linux terminal can be see on 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.

Thank you.

Niciun comentariu:

Trimiteți un comentariu