October 2, 2006

CLI Magic: Customize your comics with dailystrips

Author: Joe Barr

Here's a handy Perl script to automate a critical part of your daily routine. dailystrips can help fetch your favorite Internet comic strips in time for you to enjoy them with your first cup of coffee, without your having to surf for them. You can run it from the CLI, or set it up to run automatically each day in cron. Set up correctly, dailystrips will either create an HMTL file you can browse to read the strips, or actually download the images and store them locally for you -- your choice.

After downloading, decompress the tarball with tar xzf dailystrips-version.tar.gz or tar xjf dailystrips-version.tar.bz2, depending on which compression type you selected. You'll also need to have Perl installed, and ImageMagick too, if you're going to use the more sophisticated local mode.

To install the script, enter the dailystrips-version subdirectory and enter the command sudo perl install.pl.

At this point you can run dailystrips in several ways. If you want to read only the latest Doonesbury strip, for instance, you can get it by entering:

dailystrips doonesbury > comics.html

That's pretty cool, but you can add additional strips to the command and then have a single page to load to view them all. I have three favorite strips that I read each morning. I can use dailystrips to gather them all at once by entering:

dailystrips dilbert doonesbury userfriendly > comics.html

Think global, act local

The comics.html file created above links you to the Web site hosting the comics. You can retrieve the images themselves and store them on your own system by using the --local option on the command line, like this:

dailystrips --basedir /home/warthawg/dailystrips --local dilbert doonesbury userfriendly

Before running the command, you'll need to have created the directory given after the --basedir, in which the program stores the images it fetches. As noted in the README (there are a number of README files in the installation directory -- I recommend you read them all), you can save the command above as dailystrips.sh or whatever name you like, then include it as part of your daily cron job to run every morning. The script will create a file called index.html in the directory specified that you can bookmark and then read with your caffeine.

If you store the comics locally, you can convert them to a format you can read on your PDA by using the script's --avantgo option.

Cleaning up the webbage of the past

If you use the --local option, you will want to do a little cleanup work now and then to keep the images from taking over your disk drive. The provided script dailystrips-clean will help you do that. Just enter the the command dailystrips-clean XXX where XXX is the number of days you want to retain the strip images. Any archived images older than the number of days specified will be deleted. If you're not using the --local option, the images are never written to your disk, so you don't need to worry about it.

There are no man pages for dailystrips, but the script is well documented in the various README files, and the --help option at the command line will bring you a wealth of information.

Click Here!