simple examples of how to

Friday, December 16, 2011

how to select a package among several similar packages

in case of java, use the following


$ update-alternatives --config java

Wednesday, December 14, 2011

When you accidentally press Ctrl+S in vim

ctrl+s locks the screen and vim does not take any inputs.

Just press ctrl+q, it will release the lock.

Tuesday, December 13, 2011

gstreamer good reading sites

gstreamer all plugins list: http://gstreamer.freedesktop.org/documentation/plugins.html

about RTP streaming: http://webcvs.freedesktop.org/gstreamer/gst-plugins-good/gst/rtp/README?view=markup

gstreamer using python http://www.jejik.com/articles/2007/01/streaming_audio_over_tcp_with_python-gstreamer/

various transports and codecs using gstreamer (warning-Not english!) : http://blog.nicolargo.com/2009/02/jai-streame-avec-gstreamer.html

some vlc commandline streaming commands

@ streaming client side

vlc rtp://@:5004 # rtp stream from any source in 5004 port

vlc udp://192.168.1.1:5004 # udp stream from 192.168.1.1 in port 5004

@ streaming server side

vlc --sout udp://192.168.1.2 # udp stream to dst 192.168.1.2

vlc :sout=#rtp{dst=192.168.1.2,port=5004,mux=ts} :no-sout-rtp-sap :no-sout-standard-sap :sout-all :ttl=1 :sout-keep

[Linux] strace: live system call tracing in Linux

original article: http://linuxhelp.blogspot.com/2006/05/strace-very-powerful-troubleshooting.html

Many times I have come across seemingly hopeless situations where a program when compiled and installed in GNU/Linux just fails to run. In such situations after I have tried every trick in the book like searching on the net and posting questions to Linux forums, and still failed to resolve the problem, I turn to the last resort which is trace the output of the misbehaving program. Tracing the output of a program throws up a lot of data which is not usually available when the program is run normally. And in many instances, sifting through this volume of data has proved fruitful in pin pointing the cause of error.

For tracing the system calls of a program, we have a very good tool in strace. What is unique about strace is that, when it is run in conjunction with a program, it outputs all the calls made to the kernel by the program. In many cases, a program may fail because it is unable to open a file or because of insufficient memory. And tracing the output of the program will clearly show the cause of either problem.

The use of strace is quite simple and takes the following form:
$ strace
For example, I can run a trace on 'ls' as follows :
$ strace ls
And this will output a great amount of data on to the screen. If it is hard to keep track of the scrolling mass of data, then there is an option to write the output of strace to a file instead which is done using the -o option. For example,
$ strace -o strace_ls_output.txt ls
... will write all the tracing output of 'ls' to the 'strace_ls_output.txt' file. Now all it requires is to open the file in a text editor and analyze the output to get the necessary clues.

It is common to find a lot of system function calls in the strace output. The most common of them being open(),write(),read(),close() and so on. But the function calls are not limited to these four as you will find many others too.

For example, if you look in the strace output of ls, you will find the following line:
open("/lib/libselinux.so.1", O_RDONLY) = 3
This means that some aspect of ls requires the library module libselinux.so.1 to be present in the /lib folder. And if the library is missing or in a different path, then that aspect of ls which depends on this library will fail to function. The line of code signifies that the opening of the library libselinux.so.1 is successful.

[gcc tip] Function backtrace in the program code

be sure that you link with -rdynamic flag

#include (execinfo.h)

void print_trace()
{
const size_t max_depth = 200;
size_t stack_depth;
void *stack_addrs[max_depth];
char **stack_strings;
int i;

stack_depth = backtrace(stack_addrs, max_depth);
stack_strings = backtrace_symbols(stack_addrs, stack_depth);

for (i = 1; i < stack_depth; i++) {
printf("%s\n", stack_strings[i]);
}

free(stack_strings);
}

For more info. visit http://www.gnu.org/s/hello/manual/libc/Backtraces.html

Monday, December 12, 2011

ctags excluding patterns

ctags --exclude=*.html -R *