Misc

Misc

Robbert Haarman

2010-12-11


Introduction

This page contains various small programs I have written. Most of them do things related to backups or email. They are placed in the public domain or provided under liberal licenses in the hope that they will be useful to others. Feel free to adapt and use them for your own needs.


Disclaimer

Please note that, although I use these programs myself and they have thus been tested fairly extensively on my computer, there is no guarantee that they will behave themselves when you run them on your computer. Use them at your own risk. I do not accept any responsibility for the effects that using these programs may have on you, your computer, your sanity, your spouse, your pets, or anything else you can think of.


File Management

backup-svn-repositories

The program backup-svn-repositories creates backups of my Subversion repositories. The repositories are only kept on a single host on my network, but the backups are distributed over multiple machines by other scripts (sync-morgenes and make-backup).

Usage: backup-svn-repositories

License public domain
Language sh
Download backup-svn-repositories (192 bytes)

clean-tmp

The program clean-tmp cleans a directory of old files. By default, files older than one week are removed from $HOME/tmp, but a different directory can be specified as an argument, and a different age (in minutes) can be specified with the -t option.

Example usage: clean-tmp

License public domain
Language sh
Download clean-tmp (493 bytes)

Mail

base64-decode

The program base64-decode decodes a Base64 (see RFC 3548) encoded file. By default, it reads from standard input.

Example usage: base64-decode foo.jpg.base64 > foo.jpg.

License public domain
Language Perl
Download base64-decode (312 bytes)

base64-encode

The program base64-encode encodes a file (by default, standard input) using Base64 (see RFC 3548).

Example usage: base64-encode foo.jpg > foo.jpg.base64.

License public domain
Language Perl
Download base64-encode (338 bytes)

mailfile

The program mailfile sends a file to a number of recipients by email. Subject, content type, encoding and From: address can be specified. The encoding defaults to plain if the MIME-type starts in text/, and to base64 otherwise.

Example usage: mailfile -f sender@example.com -s 'Some Subject' -t image/jpeg foo.jpg recipienta@example.com recipientb@example.com

License public domain
Language Ruby
Dependencies base64-encode, post-message
Download mailfile (2785 bytes)

mail-parts

The program mail-parts combines a number of message parts into a multipart/mixed message and emails it to the specified recipient. Each of the parts is assumed to be a complete and valid message part as specified by RFC 2046 under Multipart Media Type. Recipient, subject, from address, mailer, and boundary (the string to separate the parts) can be specified with options. The default mailer is post-message.

Example usage: mail-parts -f sender@example.com -t recipient@example.com -s 'Some Subject' message attachment

License public domain
Language sh
Download mail-parts (1262 bytes)

post-message

The program post-message can be used to submit a message via SMTP (email) and/or NNTP (Usenet news). From address, email recipients, SMTP server, and NNTP server (as well as the port numbers to use) can be specified on the command line. The message is read from standard input. The message is parsed for a Newsgroups: header, and is submitted to the newsgroups listed therein.

The specification of from address and email recipients is compatible with the sendmail command, allowing post-message to be used to extend many programs that use Sendmail (or some replacement) to send email to also post to Usenet.

Example usage: post-message -f sender@example.com -- recipienta@example.com recipientb@example.com < message

License MIT
Language Ruby
Download post-message (5331 bytes)

Music

add-music

The program add-music adds music to mpd. I use it together with a zsh completion script (_add-music (154 bytes)).

Example usage: add-music Mozart

License public domain
Language sh
Dependencies netcat
Download add-music (173 bytes)

next-song

The program next-song plays the next song in mpd's playlist.

Example usage: next-song

License public domain
Language sh
Dependencies netcat
Download next-song (128 bytes)

previous-song

The program previous-song plays the previous song in mpd's playlist.

Example usage: previous-song

License public domain
Language sh
Dependencies netcat
Download previous-song (132 bytes)

play-music

The program play-music plays music using mpd. I use it together with a zsh completion script (_play-music (155 bytes)).

Example usage: play-music Mozart

License public domain
Language sh
Dependencies netcat
Download play-music (200 bytes)

start-music

The program start-music makes mpd start playing music.

Example usage: start-music

License public domain
Language sh
Dependencies netcat
Download start-music (129 bytes)

stop-music

The program stop-music makes mpd stop playing music.

Example usage: stop-music

License public domain
Language sh
Dependencies netcat
Download stop-music (129 bytes)

Network Utilities

bluetooth-host

The program bluetooth-host looks up the given hostname in the file /etc/bluetooth/hosts, which has the same format as /etc/hosts. It displays the MAC address of that host if found, or an error message if the host is not found in that file.

Example usage: bluetooth-host tinkerbell

License public domain
Language sh
Download bluetooth-host (442 bytes)

google

The program google uses w3m to perform a search on Google for they keywords given on the command line.

Example usage: google hidden strengths of unix

License public domain
Language sh
Dependencies w3m, urlescape
Download google (191 bytes)

urlescape

The program urlescape converts its arguments into an URL-encoded string (i.e. a string that has certain characters escaped according to the rules used for URLs).

Example usage: urlescape foo bar baz

License public domain
Language Perl
Download urlescape (241 bytes)

what-server

The program what-server submits an HTTP/1.1 OPTIONS request to a webserver and extracts the Server: header from the reply. This header supposedly tells you what software is being used for the webserver.

Example usage: what-server inglorion.net

License public domain
Language Ruby
Download what-server (474 bytes)

whois

The program whois performs a WHOIS query for the specified domain name.

Example usage: whois example.com

License public domain
Language sh
Download whois (233 bytes)

youget

The program youget takes a YouTube URL and does all the magic necessary to download the movie file it refers to.

Example usage: youget http://youtube.com/watch?v=K2cYWfq--Nw

License public domain
Language Ruby
Download youget (2701 bytes)

Other

list-dependencies

The program list-dependencies uses apt-get to determine which packages need to be fetched to install the packages named on the command line. It prints the names needed packages. This is useful, for example, if you want to fetch the packages using a different machine than the one you want to install them on.

Example usage: list-dependencies xserver-xorg

License public domain
Language sh
Download list-dependencies (364 bytes)
Valid XHTML 1.1! Valid CSS! Viewable with Any Browser