This software is free.
Some more scripts are here, including changes, the most simple version control system I know of:
ecashin@kokone tmp$ mkdir project
ecashin@kokone tmp$ cd !$
cd project
ecashin@kokone project$ for c in a b c; do echo $c > $c; done
ecashin@kokone project$ EDITOR=ed changes rec
/tmp/project/../project.changes/desc/1: No such file or directory
a
initial import
.
wq
15
ecashin@kokone project$ changes log
1 20051213-114449
initial import
ecashin@kokone project$
ecashin@kokone project$ echo new line >> a
ecashin@kokone project$ EDITOR=ed changes rec
/tmp/project/../project.changes/desc/2: No such file or directory
a
added a new line to file a
.
wq
27
ecashin@kokone project$ changes log
2 20051213-114547
added a new line to file a
1 20051213-114449
initial import
ecashin@kokone project$ changes diff
ecashin@kokone project$ echo another >> b
ecashin@kokone project$ changes diff
diff -X /tmp/project/../project.changes/dontdiff -uprN /tmp/project/../project.changes/trees/2/b ./b
--- /tmp/project/../project.changes/trees/2/b 2005-12-13 11:44:38.000000000 -0500
+++ ./b 2005-12-13 11:46:17.000000000 -0500
@@ -1 +1,2 @@
b
+another
ecashin@kokone project$ changes diff 1 2
diff -X /tmp/project/../project.changes/dontdiff -uprN 1/a 2/a
--- 1/a 2005-12-13 11:44:38.000000000 -0500
+++ 2/a 2005-12-13 11:45:40.000000000 -0500
@@ -1 +1,2 @@
a
+new line
ecashin@kokone project$
This simple script 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"
This script 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
It produces one postscript file for each source file. You may combine them with the related tool below, kern-ps-merge.
See script for simple usage and example.
See script for simple usage and example.
I have not used oinst in a while. 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.
This script was created when I was trying to please as many different versions of make as possible. I decided to avoid pattern rules and suffix rules entirely.
You use it as follows and then do "include dep.mak" in your makefile.
depgen *.c > dep.mak
You must define the makefile variables ${srcdir} and ${COMPILE} with something like this in your makefile:
srcdir = .
WARNINGS = -Wall -W -Wtraditional -Wundef -Wshadow -Wid-clash-30 -Wpointer-arith \
-Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings \
-Waggregate-return -Wstrict-prototypes -Wredundant-decls -Wnested-externs
CFLAGS = -g3
COMPILE = ${CC} ${CFLAGS} ${WARNINGS} -c
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.
addkeys is a ruby script that runs ssh-add for you.
It asks you for your passphrase and tries to use that passphrase to add all the keys listed on the commandline.
It's a good example of using the pseudo-tty and readline ruby extensions.
You use it like this:
addkeys ~/.ssh/identity ~/.ssh/id_dsa
And it will probably be most conveniently used from an alias defined in your shell startup file:
# .bashrc alias addkeys='command addkeys ~/.ssh/identity ~/.ssh/id_dsa'
taterlogs is a portable, simple log rotation script 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 very simple. You can use aliases for complex commands to keep it readable and maintainable
Do "taterlogs --help" to get usage info.
This ruby script 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.
Do "qmanip --help" to get usage info or click here.
(If the sourceforge homepage is unavailable, there's also a local location for downloads.)
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:
It uses cryptographically-secure checksums adapted from gnupg.
It can be compiled to use the Boehm garbage collection library, not for garbage collection, but as a memory leak detector.
It can produce XML output, allowing integrit to stay simple while making it easy for the user to parse, manipulate, and use the output as needed.
It uses binary cdb databases instead of plain-text databases. These are bigger than the tripwire/aide counterparts, but they allow integrit to run more lean in core. See the cdb web page for more on cdb.
Integrit's cdb code was either written by me or adapted from the cdb files that Dan Bernstein placed in the public domain. So if you're planning to use cdb in your own free applications, check out the files beginning with "cdb".
It features a nice, general file tree walking module, elcwft (ELC Walk File Tree), that overcomes some of the limitations of the UN*X ftw function by allowing the user to pass a void pointer that is passed on to the user-specified callback.
For compiling binary data, e.g., images, into a C program.
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.
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.
This is a very simple C program that can be configured to act as a wrapper that sits in the place of a program (e.g. /usr/local/bin/slirp) and syslogs each invocation before exec-ing the real binary, which lives in another obfuscated directory.
It's for lightweight, unobtrusive, selective accounting.
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.
It will compile with gcc and includes an example of its use (main.m). You can build the example by typing "make" in the unpacked Match directory.
Besides being handy, it's a good demonstration of how to use the standard C libary's regular expression support and also of how to make an Objective-C class.
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.
It's mostly ANSI C. "inline" is part of the new C99 standard, but if your compiler doesn't support the "inline" keyword, just do this to make the compiler ignore it:
#define inline
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 more interesting because it uses the Boehm garbage collector for finding memory leaks.
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.
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.
This used to be true, but now I have found that the ConTeXt macro package has a \typefile command that works nicely, and emacs has a "ps-print-buffer" function that works very well.
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.
You can do things like multiple inheritance or no-no's like getting at the object's internal data directly bad coder! :(
perldoc /path/to/xml2tex
usage:
utxreader {filename}
example:
utxreader /var/log/wtmpx | less
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