Three Command-Line Utilities

So, November is NaNoWriMo ("National Novel Writing Month"), and I was hoping to get some serious writing done (instead of coding), but I kept being distracted with coding and random writing in various Internet forums. Well, hopefully this blog post will compensate a little for that.

In this post, I'd like to cover three command-line utilities - two of them new and were written by me, and one of them somewhat older, but also written in Perl.

The first utility is GNU Parallel, which allows one to run several command-line jobs in parallel, using forking and/or ssh remote logins. I used it to speed up some processing I've been doing on my computer. For more information and some examples of usage, see my post about it to the linux-elitists mailing list, and also read Thomas Sattler's response which provides some further insights.

The second utility is countdown, which is similar to the UNIX command-line sleep command, but displays the remaining time on the console. I wrote a prototype for it in Perl 6, only to discover it consumed far too many resources. The second prototype, as a Perl 5 program consumed close to zero resources of my computer. Yesterday, I converted it to a modulino (a Perl application implemented as a module) and uploaded several versions to the CPAN.

The third utility is something I have placed in my ~/.bashrc file in order to implement reminders when the shell starts. The code for it is:

reminder_file="$HOME/.local/share/shlomif/reminder/reminder.txt"
if [ -s "$reminder_file" ] ; then
    perl -Mstrict -Mwarnings -MTerm::ANSIColor -E 'my $x = colored("===", "bold red"); say "$x Reminders $x"'
    cat "$reminder_file"
fi

Cancel_reminder()
{
    rm "$reminder_file"
}

I wrote it because I wasn't prompted in time by Thunderbird+Lightning due to a strange bug, and because I had to ditch KOrganizer because it consumed too many resources here. This displays the Reminders whenever you start a new shell, which happens quite often with me, so it's OK. I use cron jobs to append stuff into "$reminder_file", and the Perl code displays a header in colour.

That's it for today. App-Countdown is one step closer for the count-up (pun intended) towards the coveted 100 distributions under "SHLOMIF" on CPAN, so that's another plus.

5 Comments

I also run todo reminder script during shell startup :) Except that I limit it to run once a day to prevent me from ignoring it due to seeing it too much (I start many many shell sessions a day). The once-daily wrapper, or its more generic form, could perhaps be an idea for the next command-line utility.

Tried App::Countdown just now. Is there a reason it needs to be OO, BTW, because I can imagine the script being simpler without any OO. Also, to be a more proper Unix command-line utility, it perhaps needs a --help/-h and --version/-v. A shorter error message (instead of a stack trace) would be nice. As also accepting (and displaying) duration in the form of 5m, 1.5h, 0.5d (like sleep does).

Leave a comment

About Shlomi Fish

user-pic An Israeli software developer, essayist, and writer, and an enthusiast of open/free software and cultural works. I've been working with Perl since 1996.