| Scripts | Wed Feb 22, 2006 11:44:58 AST |
These are some perl and bash scripts that I wrote to aid in
system administration tasks that come my way. Feel
free to use them but do so at your own risk.
|
| mimeStrip | Wed Jun 27, 2007 11:01:30 ADT |
download
26.06.2007:
Perl had a problem with boundaries containing ++ signs.
23.07.2005:
The mime boundary was not being found if it was given in
uppercase.
12.03.2005:
There was a problem with perl 5.8, advisory locking and the
builtin STDIN, that prevented mimeStrip from running.
05.08.2003:
If no "filename" is given in the Content-Disposition, check
for a "name" in the Content-Type. Boundary match regex changed.
03.04.2003: Mixed case boundary strings were being missed in the Header's Content-Type:
03.04.2003: Some filenames were not being found
19.02.2003: Fixed a couble of bugs, see top of script for details
Strip base64 encoded attachments from mbox files. I wrote
this because Netscape messanger saves attachments in
the Sent folder.
For example,
mimeStrip -i=Sent -o=Sent.stripped -d=./Attachments
Strips all base64 attachments from the Sent folder
and puts them in the Attachments subdirectory. The
stripped attachments are referred to in the output
folder Sent.stripped.
The following modules are used in mimeStrip.pl
use MIME::Base64;
use File::Basename;
use File::stat;
use Fcntl ':flock';
use Getopt::Long;
use Time::ParseDate;
for which you may need to compile and install
IO-stringy-1.216.tar.gz
MIME-Base64-2.11.tar.gz
MIME-tools-5.316.tar.gz
MailTools-1.15.tar.gz
Time-modules-100.010301.tar.gz
libnet-1.0703.tar.gz
You can download these modules from www.cpan.org.
|
| mplayer internet radio transcription hireling | Fri Feb 24, 2006 14:37:36 AST |
This is a bash script that uses mplayer to download internet radio streams
to a file for later playback.
Download mirth
For example, to start recording at 10h00 for 90 minutes, you could do something like this,
echo "mirth mms://wm05.nm.cbc.ca/cbcr1-montreal 90 go" | at 10:00
this will save a 90 minute recording of the program in ~/mirth/go/go-2006-02-18-10:00:00.
Type mirth without arguments for help.
mirth : mplayer internet radio transcription hireling (version 0.9.0)
Copyright (c) 2006, Steeve McCauley
Usage is: mirth url len programme
url: url of program to record
len: number of minutes to record
programme: a name for your programme
Example,
mirth mms://wm05.nm.cbc.ca/cbcr1-montreal 66 go
The programme will be saved in /home/steeve/mirth/go/2006-02-18-15:07:43 where
2006-02-18-15:07:43 is the time when the script was run, or when mplayer is restarted
in case it bails out part way through recording a program.
|
| pmm2mbox | Tue Feb 7, 2006 11:57:40 AST |
download
Convert Pegasus Mail mailboxes to mbox
|
| Differential Backup | Tue Feb 7, 2006 11:57:28 AST |
download
This script will backup a specified directory. Backup
levels can be specified to backup only files changed
since the last backup at the previous level. A level
0 backup is a full backup. Level 1 backs up only files
changed since the level 0 backup. Destination files
are compressed unless they have one of the following
extensions,
@noCompressExt = (bz2,gz,tgz,Z,z,zip,rpm,gif,png,jpg,jpeg,mp3,mpg,mpeg,qic);
Destination files compressed by dbak.pl are appended
by the extention -gz to differentiate them from
files that were not compressed because of @noCompressExt.
By default, only mtime is compared to decide whether
a file has changed since the last backup level. The
file size can also be compared (this requires decompressing
each backup file so this will slow backup substantially).
One can also compare md5 digests to be absolutely sure
of file changes.
Example,
dbak.pl -s /home -d /mnt/backup -l 4 -q --purge
backup all files not found or changed in backup levels
0 through 3 from /home to /mnt/backup/4/home. Before
the backup is done the folder /mnt/backup/4/home is
purged of all files that are no longer found in
/home.
The following modules are used in dbak.pl
use File::stat;
use File::Find;
use File::Basename;
use Fcntl ':flock'; # import LOCK_* constants
use Compress::Zlib;
use Digest::MD5;
use Getopt::Long;
for which you may need to compile and install
Compress-Zlib-1.08.tar.gz
Digest-MD5-2.12.tar.gz
You can download these modules from www.cpan.org.
|
| md5check | Tue Feb 7, 2006 11:53:06 AST |
download
md5check is a perl script that can be used to verify the integrity of the
files on your system. I use it to ensure that none of my system files
have been changed, and to report when they have been changed. Kind of
like tripwire, only much easier to setup and use. I use it in a crontab
like this,
0 4 * * * ~/bin/md5check 2>&1 | mail -s md5check steeve
which checks the md5 checksums of the folders specified in the
script and compares them to those in a flat file text database.
The directories to be scanned are specified in the script like
this,
find(\&findfile, '/sbin' );
find(\&findfile, '/bin' );
find(\&findfile, '/lib' );
find(\&findfile, '/usr/bin' );
find(\&findfile, '/usr/etc' );
find(\&findfile, '/usr/games' );
find(\&findfile, '/usr/include' );
find(\&findfile, '/usr/kerberos' );
find(\&findfile, '/usr/lib' );
find(\&findfile, '/usr/libexec' );
find(\&findfile, '/usr/local' );
find(\&findfile, '/usr/lost+found' );
find(\&findfile, '/usr/sbin' );
find(\&findfile, '/usr/tmp' );
find(\&findfile, '/usr/X11R6' );
find(\&findfile, '/etc' );
The following modules are used in md5check,
use File::Find;
use Digest::MD5;
You can download these modules from www.cpan.org if
you don't already have them.
|
|
|