Wednesday, June 8, 2011

Daemonizing a script in UNIX

There are occasions when you would want to execute a script as soon as your OS boots.
The point of interest is a script my_good_work written in your favorite programming/scripting language. I have taken the example of a Dtrace script and so my_good_work becomes my_good_work.d for this post.

I describe how you do this in a UNIX based OS (Solaris to be precise)
Demonizable scripts need to be placed in /etc/init.d/. In my case, I created the boot-driver script dtrace which does nothing but sets up the command line for running my_good_work.d with its runnable parameters. The dtrace script plugs into the OS's boot framework. You need to specify actions that need to be taken when the script is executed with start and stop as command line arguments.

For example, I did (in bash)

case "start"
                 // start my_good_work.d script
                 // /usr/sbin/dtrace -s ~/my_good_work.d

case "stop"
                 // kill `pgrep dtrace`
              
esac

You can find a plethora of examples to do this in the /etc/init.d/ folder.

After this, you need to create a hard link to dtrace and place it in one of /etc/rcN.d/ folders. It really doesn't matter what N is (as far as I know). You need to create the hardlink as [S|K]NNdtrace.
S - Use this if you want to execute the script during startup
K - Use this if you want to execute the kill the script during shutdown
NN - Sequence number that is used to specify the order in which the scripts are executed.

In my case, I did

# ln /etc/init.d/dtrace /etc/rc2.d/S09dtrace

And you are done!

Note:
- Creating a copy and renaming it instead of creating a hard link will most likely won't work, neither will a soft link
- You need to be root for doing this entire exercise, because messing with boot options is not a joke!


Thursday, September 24, 2009

Funkiness

In the midst of intellectual tumult, do come such wonderful gems (so, I say since there is none else to say)

cReAtEd him, iNiTialized to JoiN me but he didn't yIeLd. I lOcKeD him up, sElf . He uNloCkEd and eXiTeD. I had to cAnCeLl and TERMINATE.

By now, you should have guessed what this means.

In any case, something that can help to figure out
1. I am a grad student.
2. I have an assignment deadline to meet tomorrow.
3. I still have to go the distance.
4. It's crapping time and what better place than Facebook to share crappiness and get recognised for it too.

So, there you go...

Still can't figure out?
I can't help iy, Google definitely can..
Go find it!

Thursday, September 17, 2009

Inspiration

Sample this...

If you'Re not faiLing eveRy now and again, it's a sign you'Re not doing anythiNg veRy inNovative - Woody Allen

One of the most insightful quotations that I have come across in the recent past.
I happen to notice it being quoted from one of my old colleague's blogs. So, it's thanks to him!

Inspiration, seldom can, not be generated through such amazing wisecracks.
Absolutely loved and loving it. At 1:19 AM early morning with a paper commentary beckoning, this should push me, hopefully :)

PS : I am a proud ".com" domain owner now. Thanks to the constant pestering of my room-mate Uday who wouldn't let me go without lapping it up.

Thursday, May 28, 2009

What to call 'em

I came up with this today, spotting a Nissan Teana, a grandiose car on the road.

Austria capital Vienna
Nissan Caru peru Teana
Asin ah Nayana?
Adhunaala enakku enna palana?


"Mudila machan" - I know!!

When India triumphed in the T20 World Cup in 2007, this was my song of success

Indha team ah gavani
Captain peru Dhoni
Vuttadhu World Cup Sani
Thodarattum ivargal pani
Ye! Dandanakka..Ye! Danakunakka

Summa..toooo much la :P
I know!!

Monday, May 25, 2009

Goodbye 800, Welcome i-20(s)

More than 13 years ago, we bought the Maruti 800, India's first budget car, the one which swept across the country's automobile industry for its simplicity, comfort and affordability. Owning the Maruti was immensely pleasing as we were among the first in our street to have a car. I was not bothered nor aware of other cars in the market back then. Apart from 800, the ones that I knew were Maruti Esteem and Maruti Zen. Infact, it took me about 3 years to question what the "800" actually signified. I simply didn't care!

Thirteen years later, it was time to move on. Senility and outdated technology of the petite car forced us to think beyond. The natural inclination was to have a bigger and improved hatchback. A hatchback is the most preferred choice that fits well into the Indian transport and parking space set up, a constraint that any middle-class car owner will acknowledge. Inquisitive about the car market these days, and with the multitude of information available on the internet, I looked to shortlist the best cars in the class.

The market is teeming with a variety of budget models - Maruti Swift Diesel and Petrol, Hyundai i-10 and i-20, Maruti Swift Dzire Diesel and Petrol, Tata Indica and Indigo. Apart from the existing ones, some new models that caught the attention were Honda Jazz and Maruti Ritz.

Choosing a car in this segment turned out to be quite a task, nevertheless an enjoyable one at that. Swift Petrol, though the initial favourite, returned poor mileage figures and both variants(diesel and petrol) ultimately lost out to the "toad-like" body image. Again, the sprawl of the bumper on the Swift was uninviting, as though the toad setting himself up to launch upon his prey. Tata was not a natural choice for a home car since their models have been widely popular only in the Taxi domain. And both the models weren't attractive either. Honda Jazz, not yet launched in India lost out to the risk factor with Honda never having known to manufacture budget automobiles.

Coming to Ritz, Maruti's hatchback offering against its extremely popular and ubiquitous Swift. My first look at the design of the car was enough to put me off. It looked as if the Dzire's back was beaten flat and then dented in the middle to shape the Ritz. There is a popular Mallu line that goes - "Adichu Ninde Shape Eh Nyaan Maathum", meaning, "I will thrash you that your body will change shape". Fitting! It did have its "butt flattened"(a phrase that might cause JLo's insurance company to panic).


A look at that car and you will know what I mean.

Swift Dzire Diesel and Hyundai i-10 were very strong contenders. While Dzire was ably backed by a strong fuel economy, the necessity to switch to a diesel engine was always going to be a question mark given the limited driving that we do. The additional one-lakh for the diesel engine made sense only if the usage matched the investment, which in our case, didn't. The i-10, from the outset looked like the Big Brother of its cousin Santro, a car which I felt was too tall and flat both in the front and rear. The need of the hour was a stylish, trendy and curvy automobile.

The i-20, designed for the European market came across as the car to beat. No bumpy headlights, lots of boot space, sleek, sophisticated, the Korean maker's impressive interiors, lovely add-on features and Hyundai's reliable record in the Indian market. The car's performance was reasonable not considering statistics like the time taken to reach 0-60 km/hr and the mileage was comparable to some of the other diesel cars.


Having booked the car and waiting for its delivery, I am reminded of the fact that, co-incidentally, there are a couple of I-20s that I am eagerly awaiting for right now. One coming all the way from the States and the other from Europe. Both have caught my imagination in equal measure.

Go, Uber Cool!

Some car related technical jargons that I have deciphered
Hatchback - The typical small car like the Swift, Santro
Saloon/Sedan - Three compartments clearly delineated - the bonnet, the seating space and the boot - Corolla, City
Limousine - A chauffeur driven car with a separator between the driver and sitting cabins
SUV - A Hatchback with larger boot space and a boxy design - Innova, Qualis