KDE based Fluxbox open folder tips

August 30th, 2008 mysurface

I am a KDE based Fluxbox user, I am face an issue that some of my gnome applications that have feature of allowing me to locate and open folder doesn’t really work as expected. Those gnome applications are gnome-do and picasa. When I open a folder from gnome-do or picasa, it will be open in firefox. Instead, I want it to open at konqueror.

I didn’t find any solution for that, due to the fact there are not much KDE based Fluxbox users around. But, at last I figure out a work around.

I realized that those gnome applications will call xdg-open when it is asked to open the folders. xdg-open is a bash script that will checks for global environment variable $DE and decide what file browser to execute. I have extracted the important part for reference:

if [ x"$DE" = x"" ]; then
    # if BROWSER variable is not set, check some well known browsers instead
    if [ x"$BROWSER" = x"" ]; then

case "$DE" in
    open_kde "$url"

    open_gnome "$url"

    open_xfce "$url"

    open_generic "$url"

    exit_failure_operation_impossible "no method available for opening '$url'"

The workaround is assign $DE with value “kde”, edit your ~/.bash_profile or ~/.bashrc with:

export DE=kde

Relogin again and it is done.

Posted in fluxbox, picasa | Hits: 106211 | No Comments »

Experiencing with vmware server and Sun xVM VirtualBox

August 17th, 2008 mysurface

Recently I have tried Sun xVM VirtualBox 1.6.4 , I have compare vbox with Vmware server 1.0.4. After couple days of testing, its time for me to share some personal findings towards them. I may not able to provide graphs, and accurate figures to shows their performance and specification, but what I do is to only share my point of view as a layman, and how I like or dislike them based on the user experience.

First of all, let me list down my host machine specs:
Dell Vostro 1400 with Intel Core 2 Duo CPU T5270 @ 1.40GHz, 2G Ram.
I use 512 Mb Ram to load my guest os, I tried loading up myrinix live CD, as well as installed Windows XP.
Uses Fedora 8, my WM uses Fluxbox 1.0.0.

Before looking into performance and features, let us first look at the screenshot! I am loading up myrinix live cd at both virtual tool. The reason I choose myrinix because this great Live CD pre install with vbox guest additions as well as vmware tools, so that I can enjoy the mouse integration to move my mouse IN and OUT the guest os.

Virtual Box have separate window for virtual os settings and guest OS itself.

Vmware Server makes every Guest OSes in MDI, separate each guest oses into tabs, and the guest os settings in sidebar, NEAT!

Read the rest of this entry »

Posted in Misc, VirtualBox, vmware | Hits: 125481 | 7 Comments »

Virtualize your operating system with qemu

August 2nd, 2008 mysurface

QEMU is a processor emulator, it allows you to run variety of unmodified guest operating systems such as Linux, Windows, Solaris, Dos etc just like Vmware and VirtualBox. In fact VirtualBox dynamic recompiler are based on QEMU. QEMU supports emulating several hardware platforms, including x86, AMD64, Alpha, MIPS, ARM, PPC, SPARC etc.

QEMU comes with command line interface, where you pass your configurations by parameters, but there are 3rd party GUI front end, such as Qemulator and Qemu-Launcher. To improves the performance of QEMU, we needs either KQEMU kernel module or KVM. Both of them are accelerator that to increase the execution speed of QEMU.

In this post, I covers installation of QEMU as well as KQEMU. As well as simple example of the use of QEMU command lines, how to create image files that allows to execute by both QEMU as well as Vmware.

Read the rest of this entry »

Posted in qemu, qemu-img, vmware | Hits: 143660 | 14 Comments »

Syslog: Sending log from remote servers to syslog daemon

July 23rd, 2008 mysurface

syslog is a standard for logging service in Linux, it usually run as daemon like syslogd or rsyslogd. Syslog daemon will be forward and store logs in /var/log directory, you may configure it to store at separate location if you want. (we will look into it later). And there is a major file that store majority of logs, which is messages. Therefore, you may want to monitor linux messages logs by tailing /var/log/message.

Logs entry may come from various services, applications, kernel as well as remote servers if you enabled your syslog daemon to accept remote logs submissions. Syslog protocol is now standardized within the Syslog working group of the IETF, and it is been defines in RFC 3164.

Rsyslog is an enhanced multi-threaded syslogd with a focus on security and reliability. I think newer linux distro already replace syslogd with rsyslogd. For more information you can check out the wikipedia.

In this post, I briefly explain the facility and log levels of syslog protocol, how to configure syslogd as well as rsyslogd to accept logs from remote and also how to send logs remotely.
Read the rest of this entry »

Posted in Admin, logger, nc, rsyslogd, syslogd, tail | Hits: 285547 | 8 Comments »

Top Ten Processes Watcher

July 13th, 2008 mysurface

top command provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. But if you want get something more specific, you must play some tricks on it. For example, I want a clean view of top ten busiest processes every seconds without those summary info, how should I do with top?

Batch mode operation
top is a real-time application that keeps display processes info sorted by cpu usage, if you redirects the outputs to a file like command line below, you will having your results mixed with ugly symbols, which is not what you want.

top > top.txt

Well, top support batch mode. By specified top on batch mode, top will display the outputs without arrange the views properly, but if you redirects it to a file, you won’t get those messy symbols mixed up.

top -b > top.txt

I just want to monitor top ten processes every seconds!
You can limits your views of top ten using head and tail, but this will STOP top from continuing to monitor the processes.

top -d 1 | head -n 17 | tail -n 11

Fortunately, we have watch to help, but you needs to put top in batch mode, and also you can ask top to stop after done displaying the result for one time. This will increase the accuracy of the result.

watch -n 1 "top -b -n 1 | head -n 17 | tail -n 11"

Posted in head, tail, top, watch | Hits: 153454 | 7 Comments »

Python vs Lua, data structure

June 28th, 2008 mysurface

In python, we have various type of data structure, such as list, set, tuple, dictionary etc, but in Lua, we only have table. Table in Lua can be used as array, list, dictionary or object.

Let see how you we construct list from Lua table.

t = { 'a','b','c','d','e','f' }

To print out the whole list, we need general for in Lua:

for i,v in pairs(t) do
	print (i," = ", v)

Lua Results:

1        =      a
2        =      b
3        =      c
4        =      d
5        =      e
6        =      f

To create a list from python:

t = [ 'a','b','c','d','e','f' ]

Print out the list with the index:

for i in t:
    print t.index(i)," = ", i

Python Results:

0  =  a
1  =  b
2  =  c
3  =  d
4  =  e
5  =  f

Read the rest of this entry »

Posted in Developer, Lua, python | Hits: 99392 | 8 Comments »

How to list shared library dependencies used by an application

June 15th, 2008 mysurface

Almost every application in Linux uses shared library, even the one compiled by yourself with gcc. You may have realized that application compiled with gcc 4.1 in Fedora or Ubuntu does not able to run under Red Hat ES3 or ES4. Or some other new applications does not able to run at legacy Linux, it is all because of missing shared library dependencies.

Is there any work around solution to allow legacy Linux uses new version of application?
My guess is as long as we resolved those dependencies completely, the application should works under any linux platform, unless the application or its dependencies required kernel version are not match.

Is there any ways to know what shared library are used by a specific application?
We can use ldd. Lets take a simple application for example. I have wrote a fun app uses ncurses library, its call “matrix”. It does nothing but simulate the running characters flow from top to bottom in the movie matrix at your linux console. You may get the source code as well as the binaries at HERE.

ldd matrix

        linux-gate.so.1 =>  (0x00110000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00111000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0793a000)
        libm.so.6 => /lib/libm.so.6 (0x0056e000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0790d000)
        libc.so.6 => /lib/libc.so.6 (0x00413000)
        libdl.so.2 => /lib/libdl.so.2 (0x00599000)
        libtinfo.so.5 => /lib/libtinfo.so.5 (0x00ad0000)
        /lib/ld-linux.so.2 (0x003f4000)

Observed that, it uses libncurses.so.5. You may find this file in /usr/lib, /usr/share/lib or /lib. Bear in mind, libncurses.so.5 probably is just a symbolic link, you need to copy the real .so instead of its symlink.

The shared library itself sometimes also have dependencies too, which it may also use some other shared library, to fully resolved that, we can add verbose to ldd for more details.

ldd -v matrix

                libdl.so.2 (GLIBC_2.1) => /lib/libdl.so.2
                libdl.so.2 (GLIBC_2.0) => /lib/libdl.so.2
                libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6
                libc.so.6 (GLIBC_2.4) => /lib/libc.so.6
                libc.so.6 (GLIBC_2.3) => /lib/libc.so.6
                libc.so.6 (GLIBC_2.1) => /lib/libc.so.6
                libc.so.6 (GLIBC_2.3.4) => /lib/libc.so.6
                libc.so.6 (GLIBC_2.0) => /lib/libc.so.6

It seems my ncurses lib uses libdl and glibc.

Posted in Developer, ldd | Hits: 216260 | 12 Comments »

Google search in command line

June 13th, 2008 mysurface

Recently I discovered a web page that provide command line interface for google search, as the author called it as Google Shell. Check out the screenshot, and also try it out at http://goosh.org/.

It does looks like unix-shell, thank to Ajax. You may think that is hilarious, but don’t make judgment before trying it out. For me, that is usable. and I should say that is perfect for CLI hardcore users.

I like google translate command line feature very much. Try this:

guest@goosh.org:/web> translate en de hello
translating "hello" from "english" to "german":


Surprisingly, when you hit tab, it does support auto complete and hitting arrow key up and down support keeping history list.

By the way, I find the idea of ordering pizza through command line is even crazy. Imagine you can write a script to loop your pizza choices and put the script to run as cron job ordering pizza as your breakfast every morning.

Posted in Misc, Network | Hits: 96667 | 10 Comments »

How to embed Lua 5.1 in C++

June 7th, 2008 mysurface

Lua, is a scripting language providing dynamic data structures, maths, io and string manipulations just like any interprete language such as Bash, Python, Ruby etc.

What is so special about Lua?
Lua is Fast, Light-weight and Embeddable.

Lua can be embedded into c and c++ programs and Lua core are statically complied with your c++ programs, meaning your c++ program itself are now becoming Lua interpreter that execute Lua scripts. To extend your c++ application to execute Lua script is simple, lets check it out.

Read the rest of this entry »

Posted in Developer, Lua | Hits: 69827 | 3 Comments »

Python: Generating graphs with matplotlib

June 5th, 2008 mysurface

Matplotlib is a python 2D plotting library that can produce dots lines, histograms, power spectra, bar charts, pie charts, scatterplots, etc. With few lines of codes, you can generate quality graphs into various image format such as eps, jpeg, pdf, png, ps, svg. You may want to check out the screenshots includes with sample codes.

I use it to generate dots and lines in my projects, there are some tips I would like to share here.

from pylab import *

plot ( arange(0,10),[9,4,5,2,3,5,7,12,2,3],'.-',label='sample1' )
plot ( arange(0,10),[12,5,33,2,4,5,3,3,22,10],'o-',label='sample2' )
xlabel('x axis')
ylabel('y axis')
title('my sample graphs')

Simple huh? First parameter of plot is x values in list, and follow by y values in list, consequently defines the types of the dot and line, at last label your lines. For saving the graphs into image, use savefig. By default, savefig uses 100 dpi, which produce 800×600 pixels image. In this example, I want to produce 640×480 pixels image, so I define the width pixels and divide it by 8.

For more examples about matplotlib, check out their tutorial.

Install Matplotlib to Red Hat ES4
I have to deploy my python script under RHES4. RHES4 installed with python 2.3 by default. To install matplotlib for python 2.3 in ES4, there are some dependencies to solve:

1. Setup setuptools-0.6c8-py2.3.egg

sh setuptools-0.6c8-py2.3.egg

2. Install numpy-1.0.4

3. Now extract matplotlib and modify setup.cfg. Mark all option as False under gui_support tag to disable GUI support.

gtk = False
gtkagg = False
tkagg = False
wxagg = False

( I don’t need show(), as my script run as background. Therefore I disable it.)

4. Install the matplotlib and you are done.

Posted in ipython, python | Hits: 83055 | 5 Comments »