Some Scripts That I Have Written
These are a load of scripts that I've written, co-written, or otherwise use. They're not 100% polished, but they weren't meant to be pretty. They were meant to be quick and dirty usable scripts. I am not responsible for anything that happens. All are licensed under the the GNU General Public License.
Note that I don't necessarily use all of these anymore, especially the ones involving MP3's (since I don't use MP3's anymore).
Perl Scripts
These scripts require Perl (duh).batchname - Renames files of the form trackxx.cdda.mp3 where xx is a number. This is the format of output files from cdparanoia once encoded to mp3 using the mlame script for lame. The script takes a filename argument which it parses to get the names to name the mp3's. The file is a newline-delimited text file with any text common to all songs (typically artist name or album name or both) on the first line. Each subsequent line has text specific for that file. Generally, you want the artist on the first line and then song titles in order on all subsequent lines. The files will retain their track numbers. It will also remove any special character cases that are annoying (generally anything needing to be escaped on GNU/Linux shells). Note: this is deprecated because of bad MP3 licensing terms. See below for the cd2ogg script
cd2ogg - Rips and encodes a cd to a set of ogg files using cdparanoia and oggenc based on a text file. Run the script with no arguments to get help. Now that I'm using grip, so I don't use this anymore.
cview - Watches your logfile using regexp matches to determine the color to print the message in. For example, intrusion detection messages show up in red. I typically run it as: /usr/local/apps/cv/xterm -geometry 100x5 -e /usr/local/apps/cv/cview 1 3 6
dar_backup - Script to automate backups using dar. This creates DVD-sized images, checksums them with parchive then burns them out to a DVD burner. I have some future improvements to this planned, which are generally centered around speed. I want to include actually verifying the archive written out to disk, but that will make things really slow, so I'll try to parallelize this; something like starting processing the next chunk while the burn and verify is going on. This should increase speed over where it is now, because the time taken will only be the actual encoding process; burning and verifying become "free". Note that this script was liked so much by the maintainer that he's been including it in his packages (or so he told me).
fixnames - Did you ever download lots of files from Windows people that have all kinds of nasty "need to be escaped" characters in it? Well, then this is the script for you. It recursively looks at all the filenames in a directory and renames them to the same thing minus the evil characters. If the new filename exists, it will print an error and not rename the file.
jtex - A nifty little script to facilitate LaTeX usage. Automagically runs latex on a .tex file specified on the command line, or the first .tex file it finds in the cwd. It then runs dvips on it, and either invokes gv or just refreshes the view. If you specify -p as well, it generates a .pdf file instead of a .ps file and displays the result in xpdf. (This is originally not mine. Credit goes to Jon Short for the original idea and Tim Toolan for the much more functional rewrite. Distributed with permission.)
mc-useradd - My useradd script. Since I use NIS, it's not as simple as a normal user add. This adds a user, makes the homedir, then rebuilds the NIS database. It also yells at you to add them to samba if you want them to have that access.
sync_podcasts - This script synchronizes a directory of files (ideally podcasts) with another directory (ideally located on a removable media player). It builds a log of files which have been successfully synchronized and only copies them once. This way, only new downloads are pushed to the device. At the end of the process, a playlist is created in each directory on the target device. Note: I use this on an iPod Nano running the excellent Rockbox firmware.
Shell Scripts
These are written in bash. Bash is required. They're pretty simple, so they may work with sh; I'm not sure.carddump - Mounts the device that my digital camera appears to be and dumps out the pics, erasing them in the process.
cdtomp3 - Rips a CD using cdparanoia and then encodes it to MP3 using the mlame script for lame.
dvdblank - Blank a DVD.
dvdformat - Format a DVD.
fastblank - Uses cdrecord to blank the pregap and Table of Contents of a CD-RW.
format - Works like the old DOS format command for formatting fat16 floppies. Calls mkdosfs and takes arguments of a or b (no colons), corresponding to /dev/fd0 (first floppy drive) and /dev/fd1 (second floppy drive).
fullblank - Uses cdrecord to blank a whole CD-RW. I only use this if fastblank fails.
govnc - Starts a vncserver with the settings I like.
ripaudiocd - Rips an audio CD using cdparanoia . An optional -na argument will stop it from aborting on skip. Arguments for track ranges are passed directly to the script.
ripcd.dd - Rips a filesystem off a CD using the dd command. It takes 1 argument that is the name of the target file. Note that this is deprecated in favor of ripcd.readcd.
ripcd.readcd - Rips an iso9660 filesystem off a CD using the readcd command (which is part of cdrecord). It takes 1 argument that is the name of the target file.
vnc - Calls vncviewer using the -via option to allow for an ssh secured connection to the remote machine. This is just to save on typing. Usage is a simple vnc remote_machinename. Note that this assumes display :1 because that is my common use case.
writeaudiocd - Writes an audio cd using cdrecord. All arguments are passed to cdrecord as options. No filenames are necessary; it automatically burns all .wav files in that directory, in the order they're listed (*.wav).
writecd - Writes a CD using cdrecord. This script is actually documented, and if you call it with no arguments, it prints a condensed version of the cdrecord man page, with the options that I use the most. Also in that file are how to create straight data cd's, audio cd's of properly or improperly sized data, and mixed mode (data and audio) cd's.
writedvd - Writes a DVD using dvdrecord. Usage is similar to writecd.
Network Scripts
These are written in bash or perl. I've grouped them together because they all interrelate. These handle network operations on my laptop. They exist because I haven't yet found a GUI tool that is as flexible and easy to use for managing multiple wireless network configs. The wired stuff is a little-used afterthought.net_down - Drops my network and removes the kernel modules for increased power savings (since the hardware seems to be disabled when the module is removed). It also kills my tunnel and drops connection to the ntp servers. Note: this is deprecated because I am now using Network Manager.
net_up - Brings up a network interface using an alternate config file specified on the command line. Usage is net_up config, so net_up home uses home.config. The config file format is:
iface ath0 inet dhcp
wireless-essid myhome
wireless-key 123487cf989802
This is just a config file passed to ifup via the -i parameter, so the documentation for interfaces applies. Note: this is deprecated because I am now using Network Manager.
ntp_down - Drops ntp access. My ntp is done by chrony, which is controlled by chronyc. Note: this is deprecated because I'm back to using ntpd.
ntp_up - Brings up ntp access. My ntp is done by chrony, which is controlled by chronyc. Note: this is deprecated because I'm back to using ntpd.
tunnel - Brings up an ssh tunnel to my email provider (leary.csoft.net). This establishes 2 tunnels. The first is for SMTP (because they don't have a hook into the IMAP over SSL (which I use to read email) to allow relaying from that IP) so that I can send mail. This is also a handy way to bypass firewalls that some ISP's put in place to "fight spam". The second tunnel is for my mail checker (the mail builtin for gkrellm), because the version distributed with Ubuntu does not do IMAP/SSL. Note: this is deprecated because I am now using autossh to manage ssh connections.
wired - Brings up my wired interface. This has a single mode (unlike wireless) so it's just a simple ifup eth0. Note: this is deprecated because I am now using Network Manager.
Batch Processing Scripts
These are written in perl. I've grouped them together because they all do variations on the same thing. These handle batch-processing operations on specific types of files, usually because there is a limit that the backend function must only work on one file at a time.pdf_pdf - Converts a bunch of pdf files to other pdf files. This may seem redundant, but it was done because the original pdf creator I used was pretty inefficient in file sizes. So, I dump it out to ps and then encode it back to pdf, which decreased the file sizes by about 50%. It takes an argument of a list of files. Simple usage is pdf_pdf *.pdf.
png_pdf - Converts a bunch of png files to pdf files. This was done because I had a pile of scanned in bits that I wanted to convert to pdf's for distribution. It takes an argument of a list of files. Simple usage is png_pdf *.png.
ps_pdf - Converts a bunch of ps files to pdf files. This was done because I had a pile of printouts saved in mozilla that I wanted to convert to pdf's for storage. It takes an argument of a list of files. Simple usage is ps_pdf *.ps.
untgz_dir - Untar-gzips a bunch of .tgz (or .tar.gz) files. It takes an argument of a list of files. Simple usage is untgz_dir *.tgz.
wpd_sxw - Converts a bunch of wpd files to sxw files. This was done because I had a pile of recipes done in WordPerfect some years ago that I wanted to convert to sxw for revision and printout. It takes an argument of a list of files. Simple usage is wpd_sxw *.wpd.