Photobucket

Sunday, May 29, 2011

Mysterious hacker and Cronjobs


I believe every blogpost has a history. Some like to share, some don't. Some can be shared, some can't. I like to share and in this case I can.

So one day, in my intern office, I was wasting a lot of time not doing my intern work and just gossiping around. So that night I decided that I will have something which will make me ask myself, what I am doing at that instant of time and also if that is what I set upon for working from the start.

First thing that struck me was something which my friend, Vaibhav Agarwal, had long ago asked me to look at when I found some time - Cronjobs. So I decided this is what I was going to use for pinging me every now and then.This reminded me of a post I had read some time ago. Desktop notifications in ubuntu using python.

So I wrote this small code and called it myst-hacker.py

#!/usr/bin/python

import os
import pynotify
import random

a = range(4)

messages = [" Whatcha doing? ",
            "Now stop being naughty and get back to work",
            "I can see everything you do ...... Muhahahaha",
            "Wazzup?"]
pynotify.init("My Application")
n = pynotify.Notification("Mysterious hacker says ...",
                          messages[random.choice(a)],
                          "/media/MY Space/Ginji.jpg")
n.show()

So all this code does is whenever it is run it shows a desktop notification like this(top right)

I made this python code executable( using 'chmod' ) and after this I was expecting to finish setting up a cronjob in 2 mins and slack off for the rest of the night.Unfortunately I thought wrong.

I believe, if you are running ubuntu 9.04 or higher, cron daemon will be automatically running each time you start your comp. So you don't have to start the daemon.So, if you are running 9.04 or higher, to set a cronjob, just do

$ crontab -e
If this is your first time then you will need to select an editor.
Then just write the time and date and the program to be run. ( You can find more details about crontab easily online)
But I did not realize I was missing something until later.

My mistake: Cronjobs which run gui commands need to be specified the display too. So it should be something like this

*/30 * * * * export DISPLAY=:0 && /home/devesh/myst-hacker.py

Remember to write the complete path to your home and not just '~' .
For more info on this check out crontab: How to run GUI programs with cron

So this is how I got mysterious hacker to ping me every now and then to remind me not to be naughty and get to my work :P.
Hope this helps someone.
Read more!

My First Android Phone.

It is important to note, in the title of this post, the word 'First'. It means there are definitely more to come :) .

Specs:
600 Mhz processor, froyo but upgradable soon to gingerbread, 3MP cam.

Here are some pics of my phone




 :D :D
I just love my phone!
Read more!