Monthly Archives: March 2009

Howto add license to sourcefiles automatically(vi)

Hi guys,

After 2 hours of learning, I finally wrote a .vimrc file which will add contents of my license file. Here is my license file file,

* <currentfilename>
* Copyright (C) <date> Mohan Raman
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <>.

and here is my .vimrc file

" Set column to 80
set columns=80

" Insert License

let licensefile = $HOME."/Development/License/GPL_v2.txt"
let currentfile = expand("%")

if filereadable(licensefile)

	let license = system("grep Copyright ".currentfile)


		execute "0r ".licensefile

		let startline = 1
		let endline = system("wc -l ".licensefile." | tr -s ' ' | cut -d' ' -f1")
		let endline = substitute(endline,"\n","","g")
		let linerange = startline.",".endline

		let command = linerange."s/<currentfilename>/".currentfile."/g"
		execute command

		let currentyear = strftime("%Y")
		let command = linerange."s/<date>/".currentyear."/g"
		execute command


First it will set column to 80. Then It will search for license file. If the file present, then It will check whether the present file already contains “Copyright” line or not. If the present fine contains “Copyright”, then it will not do anything, else, it will read the license file contents into the current file.

It also adds the filename and the current year automatically. Hope this small .vimrc will fit into your needs.

Screenshot of my newfile.c file which is processed by new .vimrc


keypressdetails plugin for gedit

Hi friends,

After a small gap, I’m back with a very interesting post, Atlast I created my own plugin for gedit, Its a plugin which will tell some details about the pressed keys.

I’m learning Gtk+ from the last september, I feel, If I came to know about Gtk, when I am In my college, I would have became very good now, But anyway, I’m learning in my part time, Now I’m able to understand something about GObject and all its greatness.

So here is my simple plugin, I attached a source tarball, which contains source file and a binary tarball with this post. Hope it will work with your machines gedit. Here is the steps to compile gedit source tarball.


1. checkout current gedit svn.

$ svn co gedit

2. Untar, keypressdetails_source.tar.bzip2 tarball and copy the keypressdetails directory to plugins directory under gedit source directory. Now Add keypressdetails directory to DIST_SUBDIRS and SUBDIRS in plugins/ Also add ‘plugins/keypressdetails/Makefile’ to AC_CONFIG_FILES in Then as usual,

$ ./
$ cd plugins/keypressdetails
$ make
$ make install DESTDIR="${HOME}"

3. Now you will see the, and keypressdetails.gedit-plugin files in your home directory. Copy these files to gedit’s plugins directory, (in ubuntu, /usr/lib/gedit-2/plugins). When you open gedit, it will automatically pick keypressdetails plugin. You can see it in edit->preferences->plugins. Select keypressdetails, and you will have one more option as Tools->keypressdetails.

Here is some screenshots,




Kadhalan BGM

Hello my friends,

Yesterday I asked Srinath, Naraen and Suganthi about what is their favourite background music? Srinath told lot of movies and he is really loving BGM, espcially from AR Rahman. Naraen also told lot of movies and suganthi already collected a bunch. After comming to room, I thought I can create BGM from my favourite movie ‘kadhalan’.

Kadhalan is a fentastic movie directed by shankar casting prabhudava, nagma, raguvaran, spb and a lot. During this time, shankar as well as rahman are new to this industry, this film made them from new to star. Rahman songs and its extrodinary BGM score will never go away from our mind.

Here I created a dozen BGM scores from this movie. All I did is,

1. Download the movie from

2. Watch it in mplayer with OSD enabled. So that I can see the exact seconds to cut the clips.

3. Use ffmpeg to cut the clips as well as convert them to whatever format you want.

I downloaded the movie from desiterminal(Kudos to you guys, thanks for the movie). Then I converted them using the below generic commandline.

$ ffmpeg -i moviepart.flv -ss starttime_hh_mm_ss -t cliplength_in_seconds \
-acodec libmp3lame -vcodec mpeg2video \
-ar 44100 -ab 128k clipfilename.mpg

Once I create the cllips, I moved them to a seperate directory. I used this below single command to dump the audio streams from the clips in mp3 format.

$ (for FILE in `ls`; do mplayer -dumpaudio \
-dumpfile "${FILE%.mpg}.mp3" "${FILE}"; done)

Thats all, I created all the interesting clips and also got them as mp3. Here is the BGMs.


I also included my favourite sceen here. After tremendous practice, prabhudeva will showcase his talent which was questioned previously by nagma. Prabhudeva learnt a critical art in bharadhanatiyam within short time where nagma learnt for a period of 6 year. She challenged prabhudeva previously and in this sceen prabhudeva takeoff his Ultra revenge. Hope all of you will enjoy!!!

Mail with Attachments (Unix shellscript)

Hi friends,

Lot of us already know howto send attachments in mails using shellscript. Lot of us already wrote these kind of script. Here is one more script to do the same thing. I already added all the details in the script itself. It is self explainable. If somebody wants, take it.

# - script to send mail with multiple attachments.
# Wrote By: me! mohan43u.
# Date: Thu Mar 06 11:56:12 IST 2009
# License: Its in public domain. Use it whatever way you can.

USAGE="USAGE: [-t tolist] [-s subject] [-e encodetype] 
	-t tolist	comma seperated e-mail addresses
				(Default: current userid).

	-s subject	Subject line (Default: 'test mail from

	-e encodetype	Encoding type (x-uuencode/base64). only GNU uuencode
			can encode in base64. If you are using this script
			in Old school unixes(solaris, HP-UX, AIX, etc) use
			only 'x-uuencode'. Linux can handle both types
			(Default: x-uuencode).

	-h		Print this Help text

This script will read standard input as a mail body and takes filenames as 
arguments to generate a preformatted mail content in satndard output. you can
simply pipe the output to any MTA (sendmail, postfix etc.,) to send a mail
with attachments.

	$ -t -s 'mail with attachments' file1 \
		file2 | /usr/sbin/sendmail -v -i -t
	hi foo,
		I attached file1 and file2 with this mail. Take a look at it.


	This above command line will attach file1 and file2 and send a mail
	to The files file1 and file2 will be encoded in
	'x-uuencode' and attached with this mail.

SUBJECT="testmail from script"
BOUNDARY="`date +'%G%m%d%H%M%S'`"

while getopts 't:s:e:h' OPTIONS
	case "${OPTIONS}" in
	t) TO="${OPTARG}";; 
	h) echo "${HELP}" && exit 0;;
	\?) echo "${USAGE}" && exit 1;;

SHIFT_COUNT=`expr "${OPTIND}" - 1`
shift "${SHIFT_COUNT}"

	echo "To: ${TO}"
	echo "Subject: ${SUBJECT}"
	echo "Mime-Version: 1.0"
	echo "Content-Type: multipart/mixed; boundary=\"${BOUNDARY}\""
	echo "Content-Disposition: inline"
	echo "User-Agent: 0.1"
	BASENAME=`basename "${1}"`

	if test "${ENCODE_TYPE}" = "base64"
		ENCODED_MESSAGE=`uuencode -m "${FILE}" "${BASENAME}" \
		| egrep -v '^begin|^='`
		ENCODED_MESSAGE=`uuencode "${FILE}" "${BASENAME}"`

	echo "Content-Type: application/octet-stream"
	echo "Content-Disposition: attachment; filename=\"${BASENAME}\""
	echo "Content-Transfer-Encoding: ${ENCODE_TYPE}"
	echo "Content-type: text/plain; charset=utf-8"
	echo "Content-Disposition: inline"

# Main

echo "--${BOUNDARY}"
echo "${BODY}"
	echo "--${BOUNDARY}"
	create_octet_part "${FILENAME}"
echo "--${BOUNDARY}--"


Hi everyone,

Last week went with full of work pressure, No time to do anything for linux. With little time, I prepared for the FossConf 2009.

While preparing, I learnt a lot from gcc, autotools and lot others. Now I have some really good exposure about gcc and its tools. I feel very happy about going to madurai.

I already told to my PL about getting leave on friday, he also accepted it. I had some deep sleep on friday afternoon. Then I started my journey at 5pm. Exactly 8.05pm the bus started from Koyambedu Bus terminal.

On saturday morning 4am, I reached Trichy, then after 3 hours, I reached Maatuthavani Bus terminus in madurai. After some little journey in TownBus, I reached Thiyagaraja Engineering College, near Thiruparangundram, Madurai.

One of the student received me and gave me a seperate room. While going to the college, someone called me, What a surprise, Amachu standing near the Thiruparangundram bus stop, I went near to him, He asked about my journey and suggested me to call Bharathi and inform him.

Once I went into the room, I felt tired and sleepy, but somehow I was awaken and had a small trial on my presentation. Then it became boring, I started to look around the confrence.

Man!! lot of school students, participating and enjoying, Baskar(linuXpert) had full of attention towards those students. “I can even take these students if they don’t want to study Higher degrees, I can give the same salary a BE guy can get, to these students, b’se they worth equal”, he said to me.

Then I saw Amachu’s Ubuntu-tam stall, So I felt that I can be a part of Ubuntu-tam. I was a person after Amachu who is helping him a lot. I introduced myself to him, by surprise, he is padu, the same padmanaban from pollachi. After sometime, amachu went away from the stall, me and padu handled students and visitors to our stall. Sametime, padu shared his experience with me, and I shared my happiness with him. One great thing is, we both are Puppy Lovers.

The afternoon 2pm I started my session, I felt disappointed about the awareness of the students, especially BE students about gcc, and its tools. So I quickly finished my session and Bharathi took from where I finished.

We both finished the sessions. Amachu asked me to give company while returning to chennai. We both started Journy at 5pm. On the way we met lot of persons from “Yahoo!!, Kerala University, DrunkenMan etc”. We boarded SETC Airbus. The Bus started exactly 6.45pm from Maatudhavani Bus Terminus. While travelling, me and amachu exchanged our views about FOSS, Tamil Culture, Upper Middle Class, Respecting others culture, culture clashes in Metropolitan cities like mumbai, bangaluru. Amachu said that he also expects this kind of clash in Chennai.

At last, at 5.45am, we reached thambaram. All in all, this weekend was a meaningful to me. I met lot of FOSS enthusiasists and Also I teached something to the students.

After all the good things, I came to hear about NRCFOSS and their .ppt presentation. A lot of discussion going on in ILUGC mailing list.

In my openion, Whatever the reason is, if an organization is named for giving awareness about FOSS, then why the people working on NRCFOSS not using FOSS tools? How they will make awareness to others? And that person KG should change his attitude when posting in mailing list, his response to Arun SAG mail is not at all acceptable.

Anyway, here is my presentation. Hope this will help someone to program using C in Linux.