linuxlogo apeekaboo.dnsalias.com
home / news
Scripts
arcade
gallery
sysinfo
links

Scripts

Here is a small selection of scripts that I've written and think others may have use for as well. Some of these scripts are written in BASH and some are written in Perl. The BASH scripts will probably not work in a regular Bourne Shell, but feel free to try, I haven't done so myself... Some of the scripts may be using features requiring BASH of version 2.x or later.

I wrote these scripts because I couldn't find any other decent tools to do what I wanted.

** DISCLAIMER **
As always: You should check scripts so you understand what they do before running them. I take no responsibility whatsoever, for any damage to your hardware (not likely...) or software (I'd hate to see that happen...) because of using these scripts. None of these script requires root privileges to run. They work on my boxen (Debian, RedHat, Slackware, Mandrake and the likes...) but they might not work on yours. They are distributed 'as is', though any tips or improvements would be appreciated.


With that being said, here are the scripts:
webupdate mamefavs howbig






webupdate version 0.17 updated February 16, 2008
   (viewed/downloaded 877 times)


:: Introduction ::
Webupdate is a perl script which monitors web pages and sends you an e-mail notification whenever they're updated. You don't manually have to visit all your favorite web pages to see if something has changed. This script does it for you!

:: How it works ::
The script calculates and stores an md5 checksum for all the content on the web page. The old checksum is compaired to the new checksum whenever the script is run. Any difference means that the web page content has changed.

In most scenarios you will add web pages interactively, and check for updates automatically via cron. Use your common sense and don't run this script too often, or your mailbox will be overflowed with notifications.... I find every 6th hour to be a good interval if you have many pages registered.

:: Features ::
You can supply a pipe with commands to filter the web page before the checksum is calculated. This will give you the opportunity to fine-grain the information that will trigger an update notification. This will also work around the problem with dynamic web pages, which otherwise may be reported as updated every single time you run the script...

You can also supply a name which describes the registered web page. This makes it easier to see what a notification is for. You don't have to parse your pipes and regular expressions in the notification e-mail.

:: Usage ::
There are two ways to run webupdate.

1) When executed without any parameters, the script is looking for updates of your already registered web pages. This is typically done via a cronjob, so updates will be searched for regularly.

Add your cron-job like this:
# run webupdate unless it is already running
0 0-23/6 * * * (pgrep -u $UID webupdate || /path/to/webupdate &>/dev/null)


2) When executed with parameters, the script expects you register a web page, with or without an accompanying pipe and/or a describing name. The pipe and the name are both optional.
Using the man synopsis, it translates to this:
webupdate www.foo.com [pipe of commands] [description]

An example could look like this:
webupdate www.foo.com "|grep bar" "My description"

You need to embrace the URL with quotes if you try to register a database-search, or if the URL includes any special characters which the shell will interpret. You always have to embrace the pipe with quotes, to prevent the shell from interpreting it. See a practical example

:: Tips ::
1) To enable compatibility with the HTTPS protocol:
Toggle FORCE_SSL_PROMPT:YES in /etc/lynx.cfg

2) Add an alias so you can view how the script sees the web page:
alias lynxdump='lynx --dump -nolist -accept_all_cookies -connect_timeout=3'
Put this in your ~/.bash_profile so it gets loaded in all new shells.

Now you can try with:
lynxdump http://apeekaboo.dnsalias.com/scripts.php

3) Please note the new file format of ~/.webupdate since version 0.13 !

:: Practical Examples ::
To monitor my web page for new versions of webupdate, you could do something like this:

1) First you need to know how webupdate sees the web page.
Open up a shell and execute:
lynxdump http://apeekaboo.dnsalias.com/scripts.php

Please note that lynxdump is an alias (see the Tips section).

2) Study the output and find a line which you know will indicate that a new version is available. You can use any commands and virtually an unlimited number of pipes to extract this information.

For this example, the following is enough:
lynxdump http://apeekaboo.dnsalias.com/scripts.php |grep 'webupdate.*updated'

3) Add this to webupdate. Be sure to quote both the pipe and the name you choose to save it as. Using single or double quotes doesn't really matter. I usually use double quotes when single quotes are used in the pipe, and vice versa:
webupdate http://apeekaboo.dnsalias.com/scripts.php "|grep 'webupdate.*updated'" \
"New version of webupdate is available"


4) Now you can manually check for updates, by running the script with no parameters:
webupdate

You could also wait for the cronjob to run automatically, if set up as in the Tips section.

:: Dependencies ::
In order to run this script, you will need the following:

  • Almost any distribution of Linux
  • Lynx
  • Perl
  • Perl modules Digest::MD5 and Term::ANSIColor (optional)

  • In Debian-based distributions, these tools are merely a command away: apt-get install perl lynx







    mamefavs updated October 06, 2004
       (viewed/downloaded 308 times)


    This perl-script displays a list of the filenames and names of your favorite ROMs specified in the MAMEWAH GUI. This script could probably work in Windows as well, although this haven't been tested. You can specify a default file to use with the script or you can pass a filename as a parameter to the script. See a screenshot of mamefavs in action.







    howbig updated October 02, 2004
       (viewed/downloaded 385 times)


    This perl-script is based on the shell-command 'du'. It takes files or dirs as arguments and shows them in ascending order based on their size.










    Contact: apeekaboo@gmail.com
    This page updated: March 17, 2008