HOWTOS and White Papers

Got questions/comments/corrections? Email me (mbates _a_t_ whoopis _d-o-t_ com).

Entries with the modification date in red have been posted or updated sometime in the past week.

Email-related | Webserver-related | System Administration | PHP/MySQL
Mac | SSH | Security | HTML/Web Development
Graphics/Dartmouth/Pranks/Other | Telephony | Random Scripts and notes | FirstClass


Email with sendmail and IMAP: [html]

Setting up sendmail with auth and ssl: [html]

Mailman Quickstart for RedHat Linux 9: [html]

Spamassassin Quickstart: [html]

Spamassassin 3.0 RedHat Linux Installation Guide: [html]

How to set up announcement or read-only mailing lists with MailMan: [html]


Web hosting with Apache VirtualHosts: [html]

Using Apache realms to password-protect your website: [html]

Using Apache's Rewrite Engine to rewrite URLs, redirect to https:, and play nice with realm authentication: [html]

Webserver Bandwidth Limiting in Apache: [html]

General System Administration (Linux, some Windows):

How to make a USB to Serial Console Connection from an Apple Macintosh to a Cisco/HP router or Switch: [html]

How to Install and Use WireShark on Mac OS X: [html]

Linux NFS Crash Course: [html]

Working with Multiple LVM Hard Disks under Fedora Core Linux: [html]

Using dummynet to Simulate a Low-bandwidth Network Connection over Two Ethernet Interfaces: [html]

iptables firewall quickie: [html]

How to Restore GRUB and/or the MBR (Master Boot Record) under Fedora linux: [html]

How to install different architecture binaries on Linux: [html]

Linux system management with Ximian redcarpet: [html]

DNS with BIND/named: [html]

Secondary (slave) DNS with BIND/named under Fedora Core 6: [html]

Setting up automatic alerting in your Unix environment: [html]

Setting up a RedHat Linux/Windows 98 Dual-boot System: [html]

Upgrading from Redhat 7.3 to RedHat 9 remotely: [html]

Linux tape backup basics howto: [html]

Adding a second hard disk under Windows: [html]

PHP, MySQL, and related packages:

How to Fix PNG Support in MediaWiki: [html]

PHP 4 and Sablotron XSLT: [html]

PHP 5 and MySQL 4 on Fedora Core 3, from RPMs: [html]

MySQL Crash Course: [html]

How to fix "Client does not support authentication protocol requested by server; consider upgrading MySQL client" problem: [html]

bBlog Quickstart: [html]

MySQL ssh tunnel quickstart: [html]

Setting up php and mysql (and phpbb) on Mac OS X 10.2: [html]

Sample PHP code: [html]

Apple Macintosh/Mac OS X:

Automatic startup of ClamXav Sentry at login for all users: [html]

How to do basic database sharing under FileMaker Pro 9: [html] (Methods here may also apply to the Windows version of FileMaker; I don't know for sure.)

How to Use Audio Hijack to Record a RealPlayer Stream: [html]

Making Resource-Fork-Aware Backups with rsync on Mac OS X: [html]

Using a Lucent Wireless Card under Mac OS X 10.3 Panther: [html]

Exporting multi-platform-compatible QuickTime movies from Apple iMovie: [html]

A Dartmouth Mac FAQ (needs updating): [html]

Importing self-signed certificates in Mail on OS X: [html]
Click here to get current sendmail and imap ssl certificate blocks for and associated domains.

Macintosh Security Basics presentation: [html]

Setting up php and mysql (and phpbb) on Mac OS X 10.2: [html]

MacSSH SSH2 Key Exchange Howto: [html]

How to Reset the Configuration of a used Apple LaserWriter 16/600 printer: [html]

How to set up Ray Arachelian's LisaEM Lisa Emulator under Mac OS X: [html]

How to Make Old Floppy Diskettes in the Internet Age: [html]

Apple repair manuals: [html]


Using CVS over SSH: [html]

Secure Chat using privoxy and ssh: [html]

MySQL ssh tunnel quickstart: [html]

MacSSH SSH2 Key Exchange Howto: [html]


iptables firewall quickie: [html]

phpBB viewtopic.php Vulnerability Hack and Forensic Followup: [html]

An incident handling analysis: [pdf]

Macintosh Security Basics presentation: [html]

HTML/Web Development:

Introduction to HTML: [html]

Intro to HTML in depth: [html]

Using Javascript to Preserve Form Contents During Browser Refresh: [html]


photoPopup Quickstart: [html]

Changing the LaserJet Ready Message: [html]

Rounded-corner rectangles in Photoshop: [html]

Creating Standalone Tcl/Tk Applications: [html]

How to load a custom map in Unreal Tournament 2004 for Mac OS X: [html]

BitTorrent Quickstart: [html]

Running OpenMCU (OpenH.323 conference server) under RH9/Fedora: [html]

sshlitzMail!: Creating and Using a Secure, Encrypted Tunnel to Access the Dartmouth BlitzMail System: [html]

BlitzMail for Linux: [html]


Home phone wiring basics: [html]

Random scripts and notes

Miscellaneous perl, bash, and PHP scripts and snippets.

#!/usr/bin/perl -w
# by Marion Bates 11-15-02. 
# This is a script to take a list of things (each on separate line)
# and write a new file with each of those things printed as a link
# to themselves. In other words, if your starting list file contains
# 	foo
# 	bar
#	foobar
#	barfoo
# and you run this script on that file, it will generate a new file
# called "linkedlist.txt" which says:
#	<a href="foo">foo</a>
#	<a href="bar">bar</a>
#	<a href="foobar">foobar</a>
#	<a href="barfoo">barfoo</a>
# USAGE: Place this script in the same directory as your file, and
# change $TheFile to be the name of that file. Then run this script
# by typing ./

$TheFile = "yourfile.txt";		# Change this part
open (INFILE, $TheFile) or die "The file $TheFile could not be opened.\n";
open (OUT, '>linkedlist.txt') or die "Oops, I can't make a new file...check permissions?\n";

while (<INFILE>) {
	$TheLine = $_;		# Tell Perl to assign the next line to our variable. $_ means "line"
	chomp($TheLine);	# Remove line breaks, we'll put them back in a sensible way
	$TheLine = "\n<a href=\"$TheLine\">$TheLine</a>"; 		# Note the escaped quotes
	print (OUT $TheLine);		# Write it out
}	# End while-loop 
# End of program


# Fix Macintosh linefeeds so the files display properly in a Unix text editor
# Usage: ./ fileyouwanttofix.txt

exec `perl -pi -e 's/\r\n?/\n/g' $1`




# Stupid little script for quickly finding songs under the strange hierarchy of the 
# iPod "Music" folder (un-hidden via "iPod MP3 Enabler")

# by Marion Bates <>
# Last updated March 31, 2004


# Count args
if [ $# -ne 2 ]
	echo -e "\nWrong number of arguments, exiting..."
	echo -e "Usage: $0 name-of-ipod songname-fragment (return)"
	echo -e "If your iPod name has spaces or punctuation in it, enclose its name in quotes, or rename it, please." 
	exit 0

# Test if the iPod they named is actually there
PODTHERE=`ls /Volumes/ | grep $IPODNAME`
if [ "$PODTHERE" = "" ]
	echo -e "\niPod named $IPODNAME not found under /Volumes/, exiting..."
	echo -e "If your iPod name has spaces or punctuation in it, enclose its name in quotes, or rename it, please."
	exit 0

# Test passed? Move on
echo -e "\nSong names containing $FILENAME are present in the following directories under\n$PODPATH:\n"

# Case-insensitive find 
# (NOTE: It needs that trailing slash for some reason, "find" is buggy maybe)
find "$PODPATH/" -iname *$FILENAME*

# Let user decide whether or not to pop open a folder in the Finder
echo -e "\nFolder to open? (E.g. \"F12\") or enter \"n\" for none."

# Not bothering to test if the folder name is valid; the open command 
# already exits cleanly if the user enters something bogus.
if [ "$FOLDER" = "n" ] || [ "$FOLDER" = "N" ]
	exit 0

# Alternate 'find' lines:
# show _just_ the folder name (char positions 3, 4, and 5) 
# find "$PODPATH/" -iname *$FILENAME* | cut -c 3,4,5 

# auto-open (bad idea without quantity-checking results; could open all the folders multiple times)
# find "$PODPATH/" -iname *$FILENAME* | cut -c 3,4,5 | xargs open

# end script

Batch renamer:

# Stick this in a dir full of files that end in
# .php and it will rename them all to .phps 

for file in *.php ; do mv $file `echo $file | sed 's/\(.*\.\)php/\1phps/'` ; done

make IP addresses into links to themselves with sed: In a file containing dot-quad notation IP addresses, this will turn each of them into an HTTP link to themselves. In other words, if the file contains

blah blah more blah blah

then this script will make that be

blah blah more blah blah

cat ip-addresses.html | sed 's/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/<a href="http:\/\/&">&<\/a>/g' > ip-addresses-links.html

burn-cd bash script:

# Usage: ./burn-cd </path-to/image.iso>

if [ $1 eq ''] ; then

        echo -e "\nNo input file specified.\nUsage: ./burn-cd /path-to/image.iso\n"

        sudo nice --18 cdrecord -v speed=4 dev=0,0,0 $1

Remote SSH port forwarding:

your_home_mac% ssh -R 2222:localhost:22 -g

.... will make listen on port 2222 and forward it over an encrypted tunnel to port 22 on your home Mac.  This is useful if the latter is totally firewalled or 192.168'ed.

If you get rid of "-g", whoopis will only listen on the loopback interface, which is a lot more secure.  (Then you can ssh to and type "ssh -p 2222 localhost".) 

If you add "-f -N" it'll detatch and do nothing but tunnel.

Redirection: In this order: 1) redirect stdout with >/some/file , 2) make stderr go to the same place as stdout with 2>&1, and then run it in the background with &

e.g. /path/to/python /path/to/script > /tmp/logfile 2>&1 &

Basic use of dd to clone a hard disk:

dd if=/dev/hda of=/dev/hdb bs=512

Single-user-mode root password reset:

(re)boot, interrupt lilo/grub and add arguments to the kernel line:


It should partly boot and dump you to a root shell. Do:

mount -o remount,rw /
passwd (follow prompts to reset)
mount -o remount,ro /

And then reboot normally.

Find/change in VI:


the g at the end replaces all instances

sed note:

echo 'c:\docsandsettings\foo\bar' | sed -e 's/^.*\\//'



Reading contents of a Mac "text clipping" from the Command Line:

If the clipping is called "snippet", do:

cat /path/to/snippet.textClipping/..namedfork/rsrc
The output will be slightly garbled, but readable.

Recursive find/change aka search and replace:

find ./ -type f | xargs perl -pi -w -e 's/SEARCH/REPLACE/g;'

    -e = execute the following line of code.
    -i = edit in-place
    -w = write warnings
    -p = loop (?)

Escape any special characters such as forward slash and . E.g. to remove all instances of absolute linking in a directory of webfiles, recursively (descend subdirectories):

find ./ -type f | xargs perl -pi -w -e 's/http:\/\/www\.somedomain\.com\///g;'

I.e. replace "" with nothing, and we had to escape the slashes and dots.

More variations (based on filename suffix):

find . -regex .*\.htm | xargs perl -pi -w -e 's/http:\/\/www\.ists\.dartmouth\.edu\///g;'
find . -regex .*\.html | xargs perl -pi -w -e 's/http:\/\/www\.ists\.dartmouth\.edu\///g;'
find . -regex .*\.php | xargs perl -pi -w -e 's/http:\/\/www\.ists\.dartmouth\.edu\///g;'

Fixing backslashes in Windows paths:


# Takes 
# 	Foobar\bar\foo\something
# and turns it into just:
# 	something

for file in * ; do 
	# echo "$file" | sed 's/^.*\\//'
	mv "$file" `echo "$file" | sed 's/^.*\\\//'`  

#^ = start at beginning of line

#. = any char

#* = zero or more times -- "greedy", so will take as many as it can

# have to double-escape the backslash in the actual execution line, because...I'm in backtics?

Using find to move/copy/etc. a whole bunch of files:

For example, to copy all files in the current directory that end in .php, to a destination directory called /home/foo, do:

find . -iname *.php -exec cp '{}' /home/foo/ ';'

Apache web log to RSS:

#!/usr/bin/perl -w
# Reads an apache weblog-format log file and provides an RSS entry for each valid line.
# based on "" by codepoet (

use strict;

my $filename = shift @ARGV;
my $cap = shift @ARGV || 0;

if (!$filename) {
print <<END
Usage: [filename] [max recent lines]

if (-f $filename) {
	my ($file, $line, @lines);
	open(LOG, $filename) || die("Could not open $filename: $!");

	print <<END
<?xml version="1.0"?>
<rss version="2.0">
		<title>$filename -- last $cap lines</title>
	my @file = <LOG>;
	for (my $ln = (@file - $cap); @file > $ln; $ln++) {
		$line = $file[$ln];
		$line =~ s/[^[:print:]]//g;
		my ($ip, $datetime, $request, $code, $something, $referrer, $useragent) = $line =~ /^(.*?)\s-\s-\s+(.*?)\s"+(.*?)"\s+(.*?)\s+(.*?)\s"+(.*?)"\s"+(.*?)"+(.*)$/;
		if ($ip) {
			print <<END

	print <<END
	close (LOG);
} else {
	print STDERR "$filename does not exist.";

Continuous feed of logfile to netcat listener:

On the host whose logfiles you wish to see:

while : ; do tail --lines=0 -f /var/log/httpd/www-access_log | nc -l 5555 ; echo -n . ; done
then from client:
nc logfilehost 5555
and enjoy the stream of loglines if the server is busy.

ucc-DM: an updated SysV init script for Unreal Tournament 2003 Dedicated Server (Linux): [text]


All kinds of good Linux info, software, etc. [link]

Process Query Systems, Inc. Security Monitoring Software [link]