Friday, August 10, 2012

BEEN PLAYING AROUND WITH LINUX. ENJOY MY FIRST BASH SCRIPT


I have been playing around with Linux, partly the reason why I have not posted on this blog for a long time. While playing with this script, my first bash script, I fell in love with it and decided to share it with you.

I am calling the script bells, because at the end of the script the system alerts you or calls for your attention. See the download links below.

For those who are not familiar with Linux, too bad!. Well, one day I will port it to Windows. One day!

What the script does is that when you initially call it, it asks you for the number of minutes you intend spending on your system.

I wrote it to keep a track of my computer time usage. I am sure most of you do read my other blog, the engagementink blog; the cartoon there of a similar thought-process must have been the trigger for this script. So, when you input the time in minutes, (fractions, negatives or alphabets are not allowed, only whole numbers), the system then starts a counter that begins counting the minutes until when it elapses, ringing bells to alert you.

On elapse, it then asks you if you want to exit the script or to continue running it. You'd usually continue if you intend spending more time on your system, but if not, the script exits and possibly, you have to shutdown your system and go on to do something else.

Now, what if you need to spend more time? Then, the script would ask if you want the counter to run for the same number of minutes as before, if you want to change the time duration, because you think rather than spend like thirty (30) minutes, you want just ten (10) minutes more to finish off a word processing file, it gives you the opportunity to change the duration for another run of the script.

At the end of it all, you might chose to exit, as I usually want to do after every hour.

Well, that is my first script written on a Linux system.

By the way, the script also listens for events or traps, such as when there is a call for all programs to terminate or when you decide that you do not want to wait for the initial number of minutes to expire; call of nature pending.
trap exitProg SIGINT ;
trap exitProg SIGTERM ;
trap exitProg SIGSTOP ;
If you use Linux, enjoy my first bash script.

I intend writing more; and telling you about them.

Nice weekend.

Download links:

Download bells.sh

Download update: bells-0.2.sh.

Just me solving problems and wondering why I was meant to be the poorest Lagosian on earth. :)


follow me on twitter, @emeka_david or be a friend on facebook, nnaemeka david