crb3's cli stuff |
|
|
Here are commandline utility programs I either wrote or changed enough that the original writer didn't want to have anything to do with them. Unless otherwise mentioned, they run on Linux. The Perl scripts might depend on tooling absent on other systems (like Win32). morbeepmorbeep is based on Johnathan Nightingale's beep, which plays tones on the (Linux) machine's speaker (so it doesn't need a soundcard). After I got done stuffing a Morse code engine into it, he preferred that I manage all that myself, so here it is. It has all of beep's capabilities preserved, plus it can play a short Morse string or a whole file at the wordrate and pitch of your choosing, with or without Farnsworth spacing. I use it to signal when a possibly-headless computer makes it all the way to the login prompt (morbeep -m ok) and when it's safe to power it down (morbeep -m bye) , and to announce the Internet connection state on my firewall box (morbeep -m up), (morbeep -m off) .
dosxfrFloppies are mortal: by now, we've all learned that. The old 5-1/4" 360k diskettes were decent at holding their bits, but the 1.2M ones, and the 3.5" 1.44M ones that followed, weren't. If you've been in the Win/DOS world since DOS, though, you've probably got a rather large collection of floppies, some of which have important stuff on them. You really should copy their contents to hard disk, or CD-R, before the bits rot any further... but doing it all manually is an incredible pain, right? This Perl script automates copying all those floppies to your Linux hard disk, one disk per subdirectory, replicating any directory trees discovered on the floppies. The diskette's own directory will be named according to any volume label found on the diskette; if none is found, according to the underlying mlabel (part of the mtools utilities, which should be part of your distribution), the script will give it a unique autolabel instead. You don't even have to mount and unmount the diskettes yourself, you just swap in another diskette every time the script beeps at you. (Don't laugh, that means you can flip to another desktop while it's working -- I put the beep in after I got it debugged.) This is the kind of tool you use for a few marathon transfer sessions and then forget all about (at least until another stashed bag of floppies shows up, or friends want all their floppies moved to CD-R), so it took me awhile to get to command-line switches. They're in now, which means you don't have to edit the script anymore. I didn't bother with copying in the boot sectors, so don't think you're successfully storing those Redmond installation disks unless you do a separate dd run, or add that into the script yourself; I doubt I'll ever get around to putting that in. rclocasrrclocasr is short for recursive lower-caser, and it works on filenames. I keep it on hand, not only because I still have to deal with files from the DOS world which arrive in 8x3 uppercase, but (because it's Perl) it's sooooo easy to copy and modify it for any little directory-recursion job I need done which isn't quite covered by some GNU tool's "-r" or "-R" switch. The recursion part is already worked out and working, and that saves me bunches of admin time.
rcgziprHere's one example of that copy-and -modify. I needed it because a simple "gzip -r *html" stops short if the cwd doesn't have anything to work on. This script doesn't. Maybe there was an obscure way to trick the standard tool into cooperating; my time was more important.
noThis Perl script is designed to make it as easy as possible for me to jot down notes and ideas, and you're welcome to use it for that too. I type no (short for note ) into an xterm, and it opens up an editor on an already-named file, in the place designated for such. (I've had ideas leak away in the time it took to come up with a good filename for them; this eliminates that mental impedance-bump.) The filenames are date-coded MIL-style (because that's unambiguous about day-and-month position, unlike numeric-only date representations). If I run it two or more times in the same day, all of those entries go in the same file, and each entry is time-stamped; this makes it more convenient for journaling, logging, and keeping notes towards a weekly progress report. If I need to add to an earlier day's entries, I type no 01jan70, if that's the target date, and the addition is time-stamped too. It's got special handling for the root account, so notes and ideas that occur to me when I'm in root rather than my normal user account go where they're supposed to (feel free to disable that if the very thought offends you). I found this to be so useful that I copied this script maybe a dozen times on my main system, one per topic, each with its own short name and storage-point, for things like memos and memoirs, fiction ideas, design and programming plans, phone-call notes and such. Then that got too bulky and I rewrote the main script to accept variables from a caller when called with 'do'. Now the various other scripts are stubs that set variables and call the main one; there's an example in the tarball linked from the show-and-tell page.
dedupededupe is a short and simple filter I brought over from my Turbo-C (DOS) stuff, where I wrote the original somewhere around 1990. It takes in a (sorted) stream of lines at stdin and emits all but the duplicates at stdout. There might be a standard GNU tool which does that, but it wasn't apparent on my first glance, so I ported something familiar.
|