pass arguments from Java to Python app

Hello readers,

I had a question by chris thompson on one of my previous posts, where I described in a short way how you can start a python script from your Java application (Link to comment), so I though, well lets face that. I basically referrer to my previous post but I adjusted some points: Continue reading

install Dropbox on a headless Ubuntu 10.04 LTS server

Hello folks,
in this post I would like to show you how easy it is to set up Dropbox on a Ubuntu server only using a ssh connection.

Ok, where to start. Hmm, first of all here is my setup:
I have a MiniITX mainboard with an Intel Atom CPU, 2GB RAM and 160GB HDD running 24/7 (almost ^_^). This system serves my as NAT Router to separate my network from the LAN in the building I am living. I bought it 3-4 years ago and it was really worth its price and by the way, energy consumption is really low (< 15 Watt). This system runs a Ubuntu 10.04 LTS server version and on this system I set up a Dropbox to have access to my account there too.

These sources were helpfull during my approach:

and basically this post is a mixture of both of them 😉
Continue reading

run SL4A python script from within Android app

Hello folks,
in this post I wanna give you a short introduction how you can launch scripts (specifically python scripts) from your android application.

To follow this tutorial you have to have SL4A installed on your device / emulator.
In case you don’t know SL4A, you can check my previous post on that: and I also found another quite good tutorial on how to install SL4A here:

Continue reading

call python script from Java app

Hello readers,

in this post I wanna give you a brief description how you can call python code from with a java program. For that purpose we will use two very simple “Hello World” programs, one in python, one for java.

First the python script. Create a new file “~/python/” with the following content:

import os
from stat import *

print "Hello World from python"

Now fire up your eclipse and create a default java application. Create a new java class named “PythonCaller”. The content of this new file will look like this:

package org.norbert;


public class PythonCaller {

* @param args
* @throws IOException
public static void main(String[] args) throws IOException {
// set up the command and parameter
String pythonScriptPath = "/home/norbert/python/";
String[] cmd = new String[2];
cmd[0] = "python"; // check version of installed python: python -V
cmd[1] = pythonScriptPath;

// create runtime to execute external command
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);

// retrieve output from python script
BufferedReader bfr = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
while((line = bfr.readLine()) != null) {
// display each output line form python script

So what is this doing? Basically we execute the python script by envoking python2.6 and provide the path to the script as parameter, as you would normally do it if you exec the script in a terminal/bash.
The output generated by the script is then read line by line with a BufferedReader and displayed in the terminal where we execute the java application.

You can execute the java program in eclipse by click on the green run button or compile and exec it in a terminal with:

cd workspace/JavaPythonCall/src/org/norbert
cd ../..
java org.norbert.PythonCaller


Hello World from python

Sweet ^_^ yeah 😉 This was a quick one, but I hope this helps.

Scripting on Android

Hello there,
so in this post I wanna tell you how you can use your favourite scripting language to write programs that run on your Android mobile phone. You know the typical way to program apps for android is writing them in java using the Android SDK. In combination with eclipse and the android development plug-in for eclipse that’s one of the easiest way to start your Android development.
But if you are not familiar with Java you probably have some difficulties to get along with learning Java first, before you can begin developing for Android.
In this post I show you a way you can use scripting languages and start directly with Android development

There is a framework you need to install on your phone called “SL4A” (Scripting Layer for Android)

Currently (MAR2012) the following Scripting Languages are supported:

  • BeanShell 2.0b4
  • JRuby
  • Lua 5.1.4
  • PHP 5.3.3
  • Perl 5.10.1
  • Python 2.6.2
  • Rhino 1.7R2

Continue reading

Teaser: Saving Audio/(Video) from Youtube with Linux

Hello folks,

yesterday evening I felt exhausted from learning for my exam on Monday.  To relax a little I did some investigation on how to download video/audio from youtube and here is a first survey:


For some time I have bing using the tool “free youtube to mp3 converter” to download some audio tracks. This tool is really awesome BUT its major drawback: It is a Windows tool 😦 . Though I have dual boot on my notebook it is a solution but not a good one, cause most of the time I am running Linux Ubuntu.


To save videos from youtube (and similar platforms) I can recommend the Firefox AddOn Downloadhelper. Since it runs very reliable in Linux Firefox too, that is the best way for me here 🙂

So yesterday evening I was looking for a way to save audio only from youtube videos. I am close to a really cool solution which I will probably post here if it is working as smooth as I assume it should 😉

But for now I have to continue my studies for my exam. So stay tuned and come back to learn more about saving audio from youtube using Linux (and its commandline 😉 )


Programming a twitter-bot using python – Part 2/2

Good morning and welcome back to my weekend project. Meanwhile it is Sunday and this is the second part on learning python by writing a small script (bot) that is able to read from and write to a twitter feed. As described in my previous blog entry, we are now able to do read / write interaction with twitter.

The plan for today is experiment with read / write access to files and combine the knowledge to read entries from a text file and post the content to a twitter feed. The relevant section of the python tutorials is 7.2. Reading and Writing Files. Continue reading

Ein ShellScript um Ordner anzulegen

Ich habe des öfteren die Situtation, das ich in einer Datei zeilenweise Ordnernamen stehen habe welche ich anlegen möchte. Da ein manuelles Anlegen sehr zeitaufwendig und unwirtschaftlich ist, habe ich mir für diesen Zweck ein kleines ShellScript, bzw. BashScript geschrieben.

while read line
	mkdir -p $line;

und für alle die wissen wollen, wie man fancy source code snippets in wordpress einfügen kann, ist hier der Link zur Beschreibung:

Continue reading