J. David Alban, Inventions J. David Alban       •       http://extasia.org/resume/       •       extasia@extasia.org

Inventions

Brief descriptions of many of my programs.  Most will operate on Linux and most UNIX platforms.

add, localtime, seconds, sub, tc, timeadd  
add   Takes two wall clock times as arguments and prints to stdout the (wall clock time) sum of the times
localtime   Takes an integer argument which represents seconds since epoch and prints to stdout date string (similar to the output of the date(1) command when invoked with no arguments
seconds   Takes string arguments similar to the output of date(1) and prints to stdout the number of seconds since epoch represented by the arguments
sub   ("subtract") Takes two wall clock arguments and prints to stdout their difference
tc   ("time calculator") An interactive (wall clock) time calculator that works in a similar manner to bc(1)
timeadd   Takes a time in a form similar to the output of date(1) and also an operator, a value, and a unit specification. If the operator is plus, the program adds <value> <units> to <time>. If the operator is a minus, the program subtracts <value> <units> from <time>. The resulting time (also in a format similar to date(1) output) is printed on stdout.
atif   ("at interface") A front end to the at(1) command. An editing session is launched containing a template that allows the user to create at jobs that email reminders. The user fills in the template, which is a shell script containing a series of at commands. The user can then edit, cat, or run this script, execute a shell command, list current at jobs, delete at jobs, and view at jobs.
atsummary   Prints a summary of the commands in all pending at(1) jobs owned by the caller
autopurgetmp   An init.d/ script. When run in an IRIX machine's startup sequence, it deletes all files and directories in /tmp, depending on the value of certain flag as reported by IRIX's chkconfig(1) command. When run in an IRIX machine's shutdown sequence it sets or unsets a certain chkconfig flag, depending on conditions on the system.
bkp_atsummary   Captures the stdout of atsummary to create a snapshot of pending at(1) jobs
bkpinbox   ("backup inbox") Creates a round-robin set of compressed copies of a user's mail spool in user (disk) space. The frequency at which these copies are made depends on cron tab entries, but is suggested to be once an hour.
catb   (named after "cat -b") Like cat(1), only each non-printable character is printed as a backslash followed by a three digit octal number (leading zeroes inserted as necessary) which represents the ascii number for that character.
cdir   ("change directory") A program which prints change directory commands to stdout based on a selection from a menu displayed to the user. It's stdout is meant to be eval'd by another shell.
cfind   ("command find") Determines a command's path given the command name. Searches a comprehensive list of directories in which executable files are typically found.
check   Lists information on *,v archive files in the current file tree
chkconfig   ("check configuration") Mimics the functionality of IRIX's chkconfig(1) command. Written for systems that don't implement chkconfig.
chkdsk, chkdskunreg, mkchkdsktabentries, showchkdskdbm   This is a suite of programs that monitors non-raid scsi disks on an IRIX system and reports problems with any of them. The disks do not have to have mounted filesystems or active partitions.
chkptfile   ("checkpoint file") Makes a copy of a file. All attributes (except for ctime :-) of the original file are preserved in the copy. Additionally, the name of the copy is the name of the original plus a suffix in the form of ".yyyymmdd.hhmmss" which represents the mtime of the original file.
chkstate   Given a string that identifies a command, and a pathname for a file that contains commands and command identifier strings, execute the command and return a boolean indicating the status of executing the command. Useful in cron jobs: e.g.:
  chkstate --command checkmount --file commands-file && do_something_else
compress_whitespace_lines.c   Converts all sets of consecutive "null lines" to a single null line on stdout where null lines are lines with no characters or lines consisting entirely of whitespace
construct_var_defns   Prints environment variable definitions to stdout based on a given configuration file. Does this in several forms, including two that can be eval'd respectively by sh-type shells and csh-type shells. The configuration file contains a host list for each variable to be defined. Invocation arguments can specify which variable definitions to print and for which hosts or contexts.
contrast   Determines the contrast (a real number) of two rgb colors given their hexadecimal rgb representations.
cronalert   Program to log and send an alert if cron is not functioning properly for a user.
cronsnap   Checks to see, using md5 checksums, whether a backup of the current crontab exists. If it doesn't, one is made.
ctab   ("crontab updater/lister") Aids users in creating and modifying crontabs. Locks a crontab using the same method employed by grab (which see). So only one process at a time can edit/modify the crontab. This is useful for sysadmins who need to update system crontabs. Also, snapshots are made in the $HOME directory of the caller. These are the previous (before user makes changes) and current (after user changes) forms of the user's crontab.
dateincr   ("date increment") Changes the system clock forward or backward the given number of seconds.
delpwent   ("delete passwd entry") Deletes an entry from /etc/passwd, identified by the arguments given
directories.lib.ksh   ksh/bash/posix sh shell function library containing shell functions dealing with directories
dmlocate, dmupdatedb, gendmlocdb, genudmldb.c   This is a suite of programs for IRIX and Unicos. It imitates the functionality of gnu's fast find utilities (locate and updatedb), but supplies additional functionality useful with SGI/Cray DMF filesystem.
dsed   ("destructive sed") Operates on files named as arguments. Takes a sed(1) operation or set thereof and applies to the files. That is, the changes are written to the files, and not just sent to stdout as they are with sed.
duchk   ("disk usage check") Examines a single directory or an entire directory tree (but will not cross filesystem boundaries) and lists files and their sizes in kbytes. Sorts in descending size order. Whitespace, shell metacharacters, and non-printable ascii characters in file names are handled correctly. Non-printable characters in file names are represented by octal escapes in output.
duration   Takes an even number of wall clock time arguments and computes:
    t2 - t1  +  t4 - t3  +  t6 - t5  +  ...  +  tN - tN-1
Each odd numbered time is the start of a duration. Each even numbered time is a temporary stop time of the duration, followed by another start time. The last time, is of course the final end time of the duration. Given all of the start times and stop times, duration prints to stdout the amount of time of the complete duration.
dvinfo   ("disk volume info") On IRIX machines, prints out disk partition info for all scsi disks.
emptydir   Shell utility to determine whether a directory is empty of non-hidden files
fakedd   Mimics the functionality of dd; wrote for a colleague for whom dd(1) wasn't functioning correctly at the target end of a network pipe
fileops.lib.ksh   ksh/bash/posix sh shell function library containing shell functions dealing with files and operations on them
finds   like find(1) except that it lists pathnames that have been modified within a given number of seconds (rather than days)
fmodchk   ("file modification check") Generate alerts when file ages or file age differences satisfy user supplied criteria
fscapck   Logs and sends alerts when filesystem reach threshold capacities
gbiff   Makes an ssh connection in the background to bring up xbiff from a remote host
generate_bkp_file_list   Prints to stdout a list of files which are to be selected for backup
genmuttcfg   ("generate mutt configuration") Generates on stdout mutt alias, save-hook, and fcc-hook information for the given file.
gpgedit   ("gnu privacy guard edit") Decrypts a PGP encrypted file (user must supply passphrase) to a temporary file (with no group or world access). Invokes an editor on the temporary file. Commits or does not commit changes after prompting user.
grab, grabinit, steal  
grab   A front end to an editor of the user's choice. Creates a lock file in a dedicated temporary directory. The first process to lock a file gets to edit it. All processes that try to edit a locked file get a full ls listing of the lock file (showing the owner, who is the user locking the file). This was useful years ago before I started using vim to edit files.
grabinit   ("grab initialize") Executed in a machines startup sequence for system installs, and by a user's .login, .profile, or other shell rc file when a user logs in. Initializes the lock directory used by grab.
steal   Goes through lock directory and facilitates easy "stealing", i.e., deleting lock files, of locked files. A user can only steal files if they have sufficient privilege. Used when the user knows that the locked file shouldn't be locked.
greplog   Prints to stdout portions of log files, based on given time ranges
hcmd   ("host command") Executes its arguments as shell commands on a list of remote hosts. The set of hosts is determined by $0. Each value of $0 (different values made possible by symbolic links) corresponds to a different environment variable which contains a whitespace delimited list of hostnames.
html_sanitize   Filters input, replacing html metacharacters with the form of those characters beginning with an ampersand and ending with a semicolon. For use when the metacharacters should be interpreted literally, and not as metacharacters.
incycle   Given cycle (e.g., "every two weeks") and a live date in that cycle, determines whether today's date (or different given date) falls in that cycle. Useful for cron jobs.
jpeg-date-rename   Renames jpeg files to include a timestamp representing their mtimes
lmrep   ("log message repeated") Replaces duplicate log message lines with the single line "last message repeated n times"
loadmail   Reads messages from an mbox style mail box into memory. Can be used as the basis for other functionality.
locate, updatedb   My own shell implementation of gnu's fast find utilities. Useful on systems which do not have gnu locate or on those on which I can't install it.
lock   Locks an xterm window (not an X11 session) with a password.
lock_with_stats   Calls an X11 screensaver and records to a log the time the display was locked and unlocked
log.lib.ksh   ksh/bash/posix sh shell function library containing shell functions dealing with logging infrastructure
Log::Monkey   perl module which logs to syslog, stderr, or a given file with optional timestamps and/or stack trace information
Log::Transcript   perl module to log data with log line headers to stderr and to a session transcript with option to email the session transcript
lsrm   Similar to "rm -i" but does an "ls -l" file listing before asking for delete confirmation
_lynx   Catenates stdin to a temporary file and invokes the lynx world wide web browser on the temporary file
mklockdir   Given a directory to create, the number of attempts to be made, and an interval to sleep between attempts, returns whether the attempt to create the directory was successful. Useful in getting locks.
mktmp.c   ("make temporary file name") An implementation similar to that of linux's mktemp(1). In mine, you don't need to supply a template. You just get a six character string designed to make a filename unique.
muttuser   Converts lines containing an alias for an email addressee, the addressee's full name, the addressee's email address, and the addressee's email folder to .muttrc text containing mutt alias, fcc-hook and save-hook commands and prints them on stdout
mylocate, myupdatedb   Mimics gnu locate and updatedb; designed for non-privileged users
no_comment   Strips comments (null lines or lines beginning with optional whitespace and then the pound sign) from input
notify_by_email   Command line tool to send email using site specific mail servers
nrcp, nrmv   Atomic ("no race") copy and move
older   Returns 0 if a file is older than a given age in seconds.
only_printable   Like cat(1) except that non-printable ascii characters are not catenated to stdout.
pfwdmail   Accepts email on stdin (from procmail) and forwards selected SMTP headers to my cell phone if the sender is in a white list
pingurl   Sends and logs an alert if it can't load a given URL
portowner   Logs and sends an alert if the process bound to a particular port is not owned by a particular application
proc_cont_lines   ("process continuation lines") Like cat(1) except that all "\\\n" pairs (i.e., a backslash followed by a newline) are deleted.
process_shutdown_state   An init.d/ script. When run at shutdown, turns off chkconfig flag indicating ungraceful shutdown. If shutdown is not graceful, then the "shutdown_complaint" flag, whose steady state is on, is not turned off. When this script is run at startup, if the shutdown_complaint flag is on, alerts sysadmins that the system may not have been shut down gracefully.
proclog   ("process log") Rotates or zeroes out a (log) file. The chosen function is performed either unconditionally, or based on filesize. Rotation can be to any desired directory. The name of the rotated file may have an "o" prepended to the original name or may consist of the original name with a suffix indicating the date and time the file was rotated.
prtacct   ("print account") Formats and prints to stdout a cbb (check book balancer) account file
psg   ("process grep") Queries the process table for a given regular expression
puncom   ("perl uncomment") Uncomments perl scripts to stdout.
purge_atsummary_backups   Purges at summary backups except for the most recent (see also atsummary)
randomxsetroot   Changes the X11 root window color to a randomly generated color
realpath   Resolves given paths to absolute paths. That is, paths which begin with '/' and contain no components which are symbolic links or '.' or '..'.
reminders   Sends email reminders depending on today's date
rockm3u   Selects random mp3 paths from a file tree and prints a random m3u play list
rs   Utility that performs rsync backups. Command line menu allows user to choose pull or push, remote host, and remote file tree.
shadrpt   Parses a shadow file to determine information on password expiration dates
showpathdef   Prints to stdout statements in shell startup files containing path definitions
shufflemp3s   From a directory full of files each containing the names of mp3 music files, prints to stdout a list of the contents of these files where the files have been chosen in random order
snap   Makes timestamped snapshots of files, preserving ownership (given sufficient privilege), mtimes, and permissions
tdist   Distributes files to a set of remote systems. Which set receives the files is dependent on $0, which, using symbolic links, is one of several shell variable names, each variable containing a different set of hosts
tlink   ("test link") Uses ping(8) to "test a link", i.e. to notify admins when host is not reachable
to, from   Programs that "harvest" and print To: and From: email addresses from mbox style mail folders
treeinfo   Formats directory tree information. Output can be used to compare file and directory attributes of entire directory trees.
treesync   ("tree synchronize") Takes two directories as arguments. Synchronizes the directory tree whose root node is the second argument with the tree whose root node is the first argument. That is, deletes anything in the second tree not found in the first tree, and creates in the second tree anything not there, but that is found in the first tree. (This was written years ago before I discovered the joys of rsync.)
uniqstr   ("unique string") Prints a string designed to make a filename unique by its inclusion in the filename.
vitalinfo   Prints to stdout a snapshot of selected system statistics.
xfe   ("xterm front end") Enhanced front end to xterm(1). Generates xterm windows with randomly selected colors. Color pairs can be selected from a file. Or two colors can be randomly chosen from showrgb(1) output. Or two random hex numbers representing rgb values can be generated. Or one of these methods can be randomly chosen.

xfe is my perl rewrite of a shell script I wrote in, and continued to develop after 1995. The current version of xfe has been "in development" since 2001. It does what I need, so I haven't finished it. I'd like one day to release it. Here is its current usage statement:

Copyright (C) 2001 David Alban (extasia@extasia.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

usage: xfe [ options ]
       xfe Invocation

options:

  -a,--attrfile [ Attrfile ]    Use randomly selected attributes from an
                                attributes file, Attrfile if given, to
                                determine colors.  The default attribute file
                                is TBD.  The default method of determining
                                colors is to generate random hex numbers as
                                color values.

  -A,--hex                      Use randomly generated six-digit hex numbers
                                as values for colors.  If a contrast threshold
                                value is specified (elsewhere), use the first
                                set of generated hex color values that
                                satisfies the contrast threshold value.
                                Otherwise use the first set of hex color values
                                generated.  This is the default method for
                                determining colors.

  -b,--bg,--background Color    Use Color as background color.  The default
                                method of determining colors is to generate
                                random hex numbers as color values.

  -c,--cr,--cursor Color        Use Color as cursor color.  The default is to
                                use the foreground color.

  -C,--contrast ContrastThreshold
                                Use ContrastThreshold as the minimum contrast
                                threshold value between foreground and
                                background colors.  The default minimum
                                contrast threshold value is 0.  The use of this
                                option never causes an error.  If it is not
                                appropriate on the given command line, it is
                                ignored.  ContrastThreshold must be a
                                non-negative integer or real number.

  -d,--debug [ DebugSpec ]      Turn on debug mode.  If DebugSpec is used,
                                the characters contained in this string will
                                govern which debug modes are selected.  If
                                DebugSpec is not used, the default mode of
                                debug information is shown.  The following
                                characters in DebugSpec result in the
                                following debug information being shown.

                                  0 => show command lines as they are expanded,
                                       colors selected.
                                       This is the default debug mode.
                                  # => general color selection info
                                  $ => Show the values of relevant environment
                                       variables at startup
                                  * => expanded command lines
                                  . => *all* debug info
                                  @ => parsed command line info
                                  a => attrfile related info
                                  A => hex color generation info
                                  b => bg/fg/cr manual color generation
                                  C => contrast info
                                  e => window command info
                                  F => font info
                                  g => geometry info
                                  H => host command info
                                  i => inline invocation info
                                  m => meta color generation info
                                  n => don't launch xterm window
                                  r => rgbdb color generation info
                                  R => show candidate rgbdb pairs
                                  s => su command info
                                  S => scroll bar info
                                  t => title (including icon title) info
                                  x => xterm args info

                                DebugSpec may not contain whitespace.

  -e,--execute Command [ ... ]  Execute Command with optional arguments.  This
                                option must be last on the command line.  The
                                default command is /bin/bash.

  -f,--foreground,--fg Color    Use Color as the cursor color.  The default 
                                method of determining colors is to generate
                                random hex numbers as color values.

  -F,--fn,--font Font           Use Font as the font.  The default font is
                                TBD.

  -g,--gm,--geometry Geometry   Use Geometry as the geometry.  The default
                                geometry is 80x40.

  -h,-?,--help                  List usage and exit with status indicating
                                success.

  -H,--host HostSpec            Connect to another host.  HostSpec determines
                                how this is done.  HostSpec must be of one of
                                the following forms:  cmd@user@host
                                                      cmd@@host
                                                      user@host
                                                      host
                                The default command is ssh.  The default user
                                is the user invoking xfe.

  -i,--inline InlineSpec        Expand InlineSpec into the command line where
                                it appears.  All such expansions are
                                preprocessed before command line processing.
                                InlineSpec may specify the location of any
                                legal xfe command line or portion thereof,
                                except that nested --inline invocations are
                                not currently supported.  

                                If InlineSpec is the name of a defined
                                environment variable then the value of the
                                variable will be inlined.  Else if InlineSpec
                                is the name of an existing file, the first
                                line in the file is inlined.

  -I,--icontitle Title          Use Title as the icon title.  The default icon
                                title is the window title.

  -m,--meta                     Randomly select a method to determine colors.
                                That is, let xfe randomly decide which
                                of the method options to use to determine the
                                colors.  The default method of determining
                                colors is to generate random hex numbers as
                                color values.

  -n,--no-window                Do not launch an xterm window.  This is useful
                                for debugging/informational purposes.

  -p,--plain,--failsafe         Cause xfe to use the xterm defaults for
                                (i.e., cause xfe not to specify):
                                     color selection
                                     scroll bar
                                     geometry
                                     font
                                     (TBD: others?)
                                Title selection (and TBD: others) will still
                                be done by xfe.  The default is for xfe to
                                make all of the selections mentioned above.

  -r,--rgbdb                    Use randomly selected colors from the rgb
                                database as values for colors.  If a contrast
                                threshold value is specified (elsewhere), use
                                the first set of selected values that satisfies
                                the contrast threshold value.  Otherwise use
                                the first set of values selected.  The default
                                method of determining colors is to generate
                                random hex numbers as color values.

  -s,--su [ - ] [ User ]        Switch user to User.  If the optional dash is
                                supplied, it is passed on to su(1) as an
                                argument.  The target user is User if given,
                                root otherwise.  If the environment variable
                                XFESUCMD is set, its value is passed to
                                su(1)'s -c option.

  -S,--summary                  List usage summary and exit successfully.

  -t,--title Title              Set window title to Title.  Environment
                                variable interpolation is performed and
                                the following backslash escape sequences
                                are supported:

            Replace       With
            ===========   ==================================================
            \$            $
            \\            \
            \~            The current working directory or '~' if in $HOME/
            \a            ("argv") the xfe command line (including $0)
            \A            The final expanded command line (including $0)
            \b            The background color
            \c            The cursor color
            \C            The actual contrast between the background and
                          foreground colors (the null string if
                          method = "attrfile")
            \e            The basename of the window command followed by its
                          arguments
            \E            The window command followed by its arguments
            \f            The foreground color
            \h            The system hostname, up to the first '.'
            \H            The system hostname
            \u            The username of the current user
            \w            The current working directory
            \W            The basename of the current working directory


  -v,--verbose [ Increment ]    Select verbose output level.  Each instance of
                                this option increases the verbose level from
                                an initial level of 0 (no verbose output, the
                                default).  If Increment is used, the level is
                                increased by that amount.  Otherwise it is
                                increased by 1.  Increment must be a positive
                                integer.  Examples:  "-v 4" and "-vv -v 2"
                                would both result in a verbose level of 4.

  -V,--version                  Print version information and exit with status
                                indicating success.

  -x,--xterm-args arg [ arg ... ] ;,--end
                                Pass arguments verbatim to xterm(1).  The -x
                                form of this option is bounded by a
                                semi-colon.  The --xterm-args form is bounded
                                by --end.  If this option is last on the
                                command line, it is not necessary for the args
                                to be bounded.  xfe does not check the option
                                arguments to this option.  The user should be
                                familiar with xterm(1) options and should
                                exercise care in choosing them.  Note that if
                                -e is used as an option argument to this
                                option, then xfe's -e (--execute) option
                                should not also be used.

Options in the set:

  { --attrfile, --background, --cursor, --foreground, --hex, --rgbdb, --meta }

are color selection options because they determine the method of selecting
colors.  They are incompatible with each other except for:

  { --background, --cursor, --foreground }

which may be used together.

The following options are "command" options and may be used only one per
command line:  { --execute, --host, --su }.

The --plain option may not be used with any of the color selection options, or
any of these options: { --font, --geometry }.

Return codes:
  TBD
    
yestlog   ("yesterday's log") Prints log entries from yesterday.
ymdhms   (name derived from a date(1) format) Prints the current date and time in the format:
    %Y<D3>%m<D3>%d<D1>%H<D2>%M<D2>%S
where:
     %Y    is the four digit year
     %m    is the two digit month
     %d    is the two digit day
     %H    is the two digit hour
     %M    is the two digit minute
     %S    is the two digit second
and <D...> are the delimiters, if any, given on the command line:
     <D1>  is $1
     <D2>  is $2
     <D3>  is $3
zclean   Disk space management tool. Compresses or deletes or truncates files in given directories.


Last modified: $Date: 2006/10/09 03:19:12 $