Search

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

3 comments:

  1. GOSH. didn't insert a title for this post. it's now done.

    ReplyDelete
  2. Fixed some bugs in the script, bells.sh. Discovered that after the initial time duration, when the user chooses to continue with the last input time, the system is not smart enough to remember the last time, rather it asks for a new inpput. Fixed that flaw. Add an introduction line to the script when it is first run, adding my name and some contact details to it. The license for the script is creative commons. The formatting of the output to the command line is well organized than that ragged looking one the script had for interface. That too was fixed.
    see what I mean here.
    https://www.dropbox.com/sh/tbyg8kqvictvcue/hXffyQrTA8/runb.png

    ReplyDelete
  3. update on script, bells: Updated bells.sh to bells-0.2.sh. Decided that if the program does not update its counter at intervals, this leaves an undetermined expectation on the user, so I decided to make the program update at intervals of ten percent (10%) of the allotted time. I think it makes the program smarter.
    Also added some colorful text to the script.

    ReplyDelete

Your comments here!

Matched content