This software is free.

code

adhocpod
Evernote
cscope dbs Linux
localcast
backup google docs
seekrw
bkp
uniq-mbox
re2c extensions
taterlogs
integrit
bin2c
syncotron
mboxsize
resume
utxreader, utxsplit

adhocpod

At github I have a simple script that creates a podcast feed for a Mac given an arbitrary collection of sound files.

Evernote

Click here to learn how to paste the clipboard text contents into Evernote as an attachment.

cscope-linux-db

cscope-linux-db is a command-line script for creating cscope databases for the Linux kernel sources.

localcast

Localcast is a command-line podcast catcher plus a mildly strange but simple hack to (in effect) indirectly get iTunes to use wget for downloading podcasts. It is inspired by bashpodder and the "Re-add Selected Tracks as Podcasts" applescript by Doug Adams.

backup-google-docs

The python script, backup-google-docs, downloads Google Documents if they have changed since the last backup.

I plan to make this script preserve old versions of the documents, but this is a start. It's more of a mirrorer than an archiver right now, but you can use rsync to archive the mirror!

It requires minimal editing for configuration. See the comments at the top of the script.

seekrw

This program (seekrw.tar.gz) transfers data from standard input to standard output using 64-bit file offsets, allowing seeks on either, and allowing the output not to be truncated.

# Put 8192 bytes from the file 20346592-8-8192 into
# the existing ../../macbook2.img file, without truncation,
# at offset 20346592 KiB.

o=`ruby -e 'puts ARGV[0].to_i * 1024' 20346592`
oseek=$o nx=8192 seekrw ../../macbook2.img < 20346592-8-8192

bkp

This simple script (bkp) is something you can run right before you run vi. It creates a dated backup of files, avoiding conflicts with other files.

[ecashin@hosty ecashin]$ bkp /tmp/testfile
bkp "/tmp/testfile" --> "/tmp/testfile.20010608"

[ecashin@ember ecashin]$ bkp /tmp/testfile /tmp/testfile-bar
bkp "/tmp/testfile" --> "/tmp/testfile.20010608_1"
bkp "/tmp/testfile-bar" --> "/tmp/testfile-bar.20010608"

uniq-mbox

This script (uniq-mbox) uses formail and procmail to remove duplicates from a UN*X mailbox file. Read it before using it, and always make backups of your mailboxes before using tools like this.

[ecashin@hosty ecashin]$ uniq-mbox /tmp/ecashin-mbox.uniq < /var/mail/ecashin
mail is in /tmp/ecashin-mbox.uniq
duplicates are in /tmp/dupsAZO8Qa

oinst software installation management tool

The oinst tool (
oinst-0.02.tar.gz) uses hardlinks to make it easy to provide central access to software installed from source without sacrificing modularity and ease of installation/uninstallation.

I have not used oinst in a while, but I leave it here because it might be the only thing here that uses the Objective Caml programming language.

I like this better: install source-built programs in a fully-versioned directory in /opt, like "/opt/tla-1.0.1". Then create symlinks as necessary in /opt/bin and /opt/man, etc. It's not much pain, because I only have to symlink the stuff I use enough to need it in my $PATH.

host access rules for mini_httpd

This patch adds IP-based access control to Jef Poznaker's mini_httpd.

mini_httpd is a small web server that can do SSL. My patch applies against mini_httpd version 1.17beta1. After applying the patch and editing the makefile to point to your configuration file, you can configure mini_httpd to accept or refuse connections based on IP, using a configuration file like this:

accept:128.192.1.9
accept:192.168.0.0/16
deny:127.0.0.1/8
deny:

As you can guess, this configuration allows connections from host 128.192.1.9, and from any IP beginning with 192.168, regardless of the second half of the IP. (The first 16 bits of the 32-bit address are significant.) It doesn't accept connections from anyone else. The empty address after the last "deny" is equivalent to "0.0.0.0/0".

Please let me know if you use this patch — I'd like to hear feedback.

re2c extensions

These files (scanner.c and scanner.h) provide support to the re2c scanner generator. There's an example of how to use these files embedded in scanner.c ... it's the lex function between "#if 0" and "#endif".

taterlogs

This log rotation script (see taterlogs and skeleton taterlogs.conf file) is portable and simple, written in perl with compression support and support for commands to run after rotation.

Unlike Linux's logrotate, taterlogs only runs a given post-rotate command once, so if you have lots of logs created by one daemon, e.g., syslogd, then that daemon only gets HUP'ped once.

The configuration file is easy to use. You can use aliases for complex commands to keep it readable and maintainable

Run "taterlogs --help" to get usage info.

qmanip

This ruby script (qmanip) has a similar function to the script, "qtool.pl", which comes in the sendmail distribution's contrib directory. It allows a sysadmin to manipulate live mail queues without shutting down sendmail.

The way that's possible to do safely is that qmanip, like qtool.pl, uses the same kind of file locking that sendmail itself does.

Run "qmanip --help" to get usage info or click here.

integrit

The integrit file verification system is a project housed at Sourceforge that is for intrusion detection. Its design goals include simplicity, security, convenient unattended operation, and a small memory footprint.

I wrote it because I use intrusion detection systems at work to determine whether or not our servers have been compromised, and of the two systems we use, both are overly complex and both take up a lot of memory at runtime, but one is bloatedly complex and the other has a whopping great memory footprint that has no runtime limits and could take down a server.

Some interesting things:

bin2c

The bin2c (AKA bin2h) program compiles binary data, e.g., images, into a C program.

It reads in a binary and creates C code on standard output that has a character array that holds the binary data.

I wrote this program because I found similar programs (often called bin2h) that had arbitrary limits on the size of data.

Syncotron Bathysphere Sound Suite

The Syncotron Bathysphere Sound Suite is a project housed at sourceforge that uses a distributed design to create an interactive sound environment.

mboxsize

This (mboxsize-20010214.tar.gz) is a UN*X tool for showing the size of individual messages inside of a UNIX-format mailbox file. In addition to the size in bytes, it displays the contents of the subject, from, and date headers.

It has a variety of output formats, including XML and line output with user specified field delimiters:

It can reset the access time of the mailbox it reads. (So that finger info about the time the mail was last read doesn't get messed up.)

usage:
    mboxsize [ -h | -r | -x | -D | -d DELIM ] [-a] [mbox]
options:
    -h show this help
    -a reset access time
    -r use multi-row output format
    -x use XML output
    -D set output delimiter to "|--|"
    -d set output delimiter to DELIM

The default output format looks like this:

2849   Re: multi-column spread Ed L Cashin <ecashin@co 13 Nov 2000 13:43:06 -05
2140   Re: multi-column spread Ed L Cashin <ecashin@co 13 Nov 2000 13:44:19 -05
2126   Re: M-Math; \placeformu Tobias Burnus <burnus@g Mon, 13 Nov 2000 21:25:4
2271   last questions, urgent  Hraban <angerweit@gmx.n Mon, 13 Nov 2000 21:56:3
2392   Re: beginner's question siepo@cybercomm.nl      Mon, 13 Nov 2000 22:26:0
8382   Re: Fwd: Re: beginner's siepo@cybercomm.nl      Mon, 13 Nov 2000 22:26:3

mboxsize is a good example of a simple program that uses a fast scanner generated by flex for its lexical analysis

That just means that instead of writing C code to look through the mailbox, I wrote a short list of regular expressions and corresponding actions in an input file for flex. flex generates optimized C code to look for the patterns that I specified.

An alternative to flex is re2c. It generates even faster C scanners than flex does. It's more flexible than flex, but it takes a bit of getting used to.

resume

This (resume-generic-20001015.zip) is a generic resume written for the ConTeXt macropackage.

This code uses ConTeXt macros to describe a document, and ConTeXt uses pdfTeX behind the scenes to create a really nice looking resume.

Because this resume uses some cutting-edge ConTeXt features, it has a short HOWTO explaining how to upgrade pdfTeX and ConTeXt in a UNIX teTeX installation.

hashtbl

Here is a simple and flexible hash table package in C. I wrote it a long time ago, but it is probably still useful and/or interesting.

Its structure is loosely based on the examples in K&R2, its hash function is from cdb, a database by the smart D. J. Bernstein, and with optimizations based on glib.

xstradd

xstradd has a couple of C functions for adding together an arbitrary number of strings.

To use:

char	*oldstr	 = "an old string";
char	*newstr	 = xstradd("This is ",
			   __FUNCTION__,
			   " so fun (",
			   oldstr, ")",
			   NULL);

puts(newstr);	/* use newstr */

free(newstr);

It's a little interesting because it uses the Boehm garbage collector for finding memory leaks.

FreqSpec and the samplomatic

FreqSpec.h and FreqSpec.m are the header and implementation files, respectively, for a frequency analyzer written in Objective-C.

I used the POC to pre-compile the Objective-C into C code, but you could also use gcc (I bet). The current version of FreqSpec is part of the samplomatic, which does compile with gcc.

FreqSpec uses the Fastest Fourier Transform in the West (FFTW) library for the actual Fourier transforms. The library is interesting because it is self-optimizing: it creates an algorithm on the fly based on the idiosyncrasies of the machine it happens to be running on.

To use, you set it up and then send it a zero-terminated array of frequencies for the bands you want. If you are reading this with interest, contact me (see my home page for contact info), and I'll put more info here.

backup.sh

backup.sh is a (Bourne) shell script that uses tar to write backups to your SCSI tape drive.

The nice thing about this script is that it uses the ability of SCSI tapes to "tell" and "seek" block positions on the tape. backup.sh prints a list of block numbers so that you can ...

# seek the position of the tar dump for /var (known from backup.sh)
mt -f /dev/nst0 seek 658100
tar xvf /dev/nst0 var/log/secure

Here's a robust way to print the index from backup.sh:

tmp=$HOME/.tar_backup.tmp
nice -n 18 /adm/tools/backup.sh > $tmp && mpage -4 < $tmp | lpr || {
      echo error with backup.sh, see $tmp.  exiting. 1>&2
      exit 1
}

This article for Sysadmin Magazine extends this idea to multiple machines on a network.

Berend de Boer has made contributions to the solution described in the Sysadmin article. They're on the papers page.

norepeatogrep

norepeatogrep-20000225.tar.gz

This is a program written in C as a drop-in replacement for egrep as used in the logcheck system.

It is different in that it recognizes repeating log entries, and if there is an ignore rule for a given message, e.g.,

sshd.* log: RSA key generation complete.
... and there is this in the log:
Mar 16 23:08:24 schmu sshd[30386]: log: RSA key generation complete.
Mar 13 14:43:34 schmu last message repeated 18 times
Mar 13 14:43:34 schmu last message repeated 4 times
Mar 13 14:43:34 schmu last message repeated 2 times
... then "nrgrep" will ignore all four lines. Other, non-ignored lines, get printed out along with any "last message repeated n times" messages.

Let me know if you are interested in this and I'll clean it up and document it.

encapsul.pl

This is a perl script (encapsul) that shows a simple demonstration of perl's data encapsulation support. This file shows a rudimentary object in perl. Perl's support for Object-Oriented Programming is very flexible and not very strict.

utxreader

This is a C program (utxreader.c) that can display the contents of arbitrary wtmpx-format binary files. wtmpx or utmpx is the format that the "last" facility on UNIX-like systems uses.
utxreader.c

usage:
	utxreader {filename}
example:
	utxreader /var/log/wtmpx | less

utxsplit

This is a C program (utxsplit.c) that can read select records from arbitrary wtmpx-format binary files and write those records to a new wtmpx file. wtmpx or utmpx is the format that the "last" facility on UNIX-like systems uses.
utxsplit.c

usage:
	utxsplit {-b beginning_record} {-e ending_record} \
		{-i infile} {-o outfile}
example:
	utxsplit -b 51 -e 100 -i /var/log/wtmpx -o 51-100.wtmpx

gpl.pl

This is a perl script (gpl.pl) that adds a commented GPL header to source files. It can do C-style and script style ("#") commenting. Type ./gpl.pl -h for usage.
I have to call the file gpl.perl because of the way our server works.

joe random

The Joe Random Sequencer is a C program that compiles with djgpp into a 32-bit DOS application. It plays wav files as samples with random pitch, volume, panning, and timings. You can turn off the randomness or limit it to a given range for any attribute of any sound.

Unfortunately, arches removed my web page, and I haven't been able to find any old hard drives containing Joe Random yet. Please let me know if you have a copy.


Some more scripts are here.