Category Archives: Unix

I needed a catagory for stuff that was general unix, and not nessessarily linux specific

quick and dirty dns lint

I run a DNS server that I and a lot of my friends use. The problem with it being “free” and being between friends is sometimes people forget to tell you if they have switched DNS serving arrangements or just haven’t kept the registration.  I wrote a quick and dirty script, thanks to the whois ruby gem, to check to see if all the domains listed in Bind9‘s named.conf are still registered and if so do they still have our nameserver listed as one of the nameservers.  g0ff asked me for a copy, so I thought it might be useful to share with others.

require 'rubygems'
require 'whois'
zones =
ZONE_RE = /^zone "(\w+.\w+)" in/[0]) do |f|
  f.each_line do |line|
    md = ZONE_RE.match(line.chomp)
    zones << md[1] unless md.nil?
NS_RE = /^#{ARGV[1]}$/i
zones.each do |zone|
  c =
    domain = c.query(zone)
    if domain.registered?
      if domain.nameservers.detect { |ns| !NS_RE.match( }.nil?
        puts "#{domain.domain} doesn't seem to have us as a dns server"
      puts "#{zone} doesn't appear to be registered"
  rescue Whois::ResponseIsThrottled
    sleep 120
    c =

Thanks, Steve

Steve Jobs passed away today at age 56 after a battle with cancer.  Here’s a few random thoughts…

On this day, I own a buttload of Apple gear: iPhone, iPod, iPad, MacBook Pro, Apple TV, Apple TV 2, Time Capsule, Mac Mini… I’m planning on getting an iPhone 4S as soon as possible.

I was (and am) a big open source dork at heart, but Apple’s simplicity and ease of use, especially the past 7 years really spoke to the pragmatic side of me.  It turned me into a fan boy, I guess.  It didn’t hurt that OS X is NeXTStep is UNIX… I touch OS X and Linux every day.

One of Dinah’s first words was iPod which she taught herself so she could ask me to turn on music for her.

In college, I loved using the NeXT computers we had. My first class in college used scheme on the NeXT’s. The NeXT is one of the first places I played Doom.  I took calculus using Mathematica on the Mac in college.

Steve also touched my kids’ lives via Pixar. (Okay, my life too, I saw Toy Story in the theater first run, long before I had kids.) Also through their first computer, a Mac Mini.

There were too other public figures who’s lives and deaths touched me the way Steve’s passing is touching me today: Jim Henson and Fred Rodgers.

Tivo2Podcast update

I’ve made a few updates since my last release a few weeks ago. I thought I’d toss an updated version out there.  What’s new in this version:

  • Duration is no longer hard-coded to 32:00 and actually reflects the duration of the show
  • The script will attempt to find the TiVo via Bonjour/mDNS/ZeroConf/DNS-SD/whatever unless passed a -t flag with the TiVo’s IP address. If you have more than one TiVo, it will go with the first one it finds.
  • Moved the stuff in lib to lib/tivo so the package is more easier sucked in by something like encap or stow

Download: tivoscripts-20100314.tar.gz

When I get some motivation later in the week, I’ll put the git archive online, incase anyone wants to clone it and do some development on it.

TiVo -> Video Podcast

Previously on “You can imagine where it goes from here”: We released a script to download stuff from the tivo, and then made some improvements to it.

After two years of saying I was going to fully automate the process of downloading and transcoding shows for my iPhone, I finally got off my ass and did it.  The script is called TiVo2Podcast and it not only does the downloading and transcoding, but it stuffs the resultant video into a an RSS feed for easy consumption/playback by a podcatcher such as iTunes. I’m now automatically getting the shows off my TiVo and onto my iPhone for easy commute-time consumption. (I commute by train, I do not recommend commute-time consumption if you are driving.)

The ruby script wraps tivodecode, HandbrakeCLI, and AtomicParsley and is intended to be run from cron.  I’ve tested this on Linux, but it should run on any UNIX-alike, but it won’t run on windows since I make liberal use of the system() call. Also, this is intended for PERSONAL USE ONLY, do not set up podcast feeds and violate the ethics (and also the laws) of copyright left and right.

This is a very early version and can certainly use some tweaks and enhancements, primarily in configuring the shows you want to capture.  Right now, configuration is in the form of doing INSERT statements in SQLite.  Not very friendly, but it gets the job done until I can make a quick and dirty question based TUI. Here’s an example of setting up getting the best fucking news team on the planet:

INSERT INTO configs (config_name, show_name, rss_filename, rss_link,
                     rss_baseurl, rss_ownername, rss_owneremail, ep_to_keep, encode_decomb)
            VALUES ('tds', 'The Daily Show', 'tds.xml', '', 
                    '', 'Keith T. Garner', '', 4, 1);

Download tivoscripts-20100304.tar.gz and let me know what you think. Make sure you read the README!

[Update 3/5: Forgot to add that all the code I wrote is under the Simplified BSD License, so have at it.]

Fix/Tricks for plugin auto-update on WordPress 2.5

[READ THIS FIRST!!!  Update 6/13/2009: If you’ve come here looking to get plugin updates to work and you’re using WordPress 2.8, you really want to start with this more recent post on the topic and then come back for the permission information.]

One of the neat features of WordPress 2.5 is the click to install plugin upgrades, assuming the plugin is registered in the WordPress Plugin Directory. If certain conditions are correct on the server it can do it in place, otherwise it tries to do it via FTP.

To make it so wordpress could upgrade them on the server without FTP requires doing some permission changes. You should be aware, the changes I made allow the web server (Apache) to be able to write to the plugin directory. This creates some security exposure. Since I do nightly backups, for me this is an acceptable risk. You may make a different call.

The way I’ve done it also assumes you have admin rights on the unix box or you’re friendly with (s)he who does. Without admin rights to do the group ownership changes, you’re stuck having to make files writable by the world, and that’s not something I’d do. Luckily, I hold the power on the box(es) I care about. Continue reading Fix/Tricks for plugin auto-update on WordPress 2.5

Preach on (about SSH,) Brother Dave

openssh.pngDave Dribin wrote up a nice post about people breaking some of the first ‘s’ in ssh and how that annoys him and ways to get around it. Its really a good read and really hammers home the point of using ssh-agent, which Dave initially exposed me to. Being able to ssh around without typing my password each time was something I was missing back from when I had kerberized ssh back at UIUC.

While I agree with Dave about the empty password thing, one thing you can do in your .ssh/authorized_keys file is lock down a key to a specific IP and to a specific command. So, while you may have a passwordless ssh access, you can somewhat mitigate the risk by locking down what they can can do. For example, with a key truncated because it is long:

from=”″,command=”/usr/bin/uptime” ssh-rsa AAA…

With this addition in the authorized_keys section, a user with this key from will only be able to execute /usr/bin/uptime. For more information on that and other options you can use, see the AUTHORIZED_KEYS FILE FORMAT section of the sshd(8) man page.

CMake so far

I’ve been investigating cmake at work as a better build system for our cross platform C based projects. I’m thinking about starting up a third one, so now is the prefect time to really go after this as for one project we have a build system per platform and on the other we have two build systems. When you mix in wanting to make universal binaries on OS X its yet another wrinkle. cmake was recently chosen by KDE to be the build system for KDE4 since KDE4 will be fully supporting Windows and OS X, as well as the other unicies via X. I used a small convenience library as the test piece as it was only two files big, but it had the requirement of at least two external libraries.

Some pros for cmake that I’ve found so far (compared to what we’ve been doing):

  • support a big number of build environments on the different platforms. On windows it sports 11 different build environments, OS X 3, and Linux 2. For OS X and Linux, you only really need those two or three, but on windows it supports 4 different versions of visual studio as well as Borland, Watcom, and gcc.
  • Takes care of the flags needed to build executables and libraries on those supported platforms.
  • Does out of source builds on windows.
  • Tracks dependences on all platforms without an external application
  • Does search and replacing on things like .in files without having to call out to external applications

Some cons I’ve found so far:

  • The documentation on the web page is pretty horrid. The book is pretty bad too, especially when compared to other technical books I’ve read recently, but its much better than the website. When combined with the book and experimentation, the FAQ is helpful.
  • Doesn’t really have the concept of convenience libraries. This will result in common files being built multiple times. I don’t like this, but its not fatal.
  • The CMakeCache is getting in my way more than being a help, but that might be the side effect of my learning process right now.
  • I haven’t yet figured out how to make it query the person compiling the app if it can’t find something. This may not be possible. At the very least I want to make it bitch and bomb out if a required dependency isn’t there. I just haven’t found it yet, I’m thinking.

This isn’t an exhaustive review yet, but I wanted to get down what was in my mind before I forgot. I had just found the convenience library thing and that’s what inspired the post. My next step is to move a full existing project over to being built with cmake. This is a library that depends on expat, boost, curl, antlr, and (optionally) swig. Should be a good challenge.

[Update 11:58: I found an answer to my “bomb out if the dependencies are missing” question. Thanks, devchannel!]

[Update 2:51: No this isn’t here just for g0ff. Turns out the latest cmake has modules to Find Java, Doxygen, Boost, Curl, Expat, and Swig already. It looks like just custom items for antlr and cppunit will be needed. Also, it only ever wants to link against dynamic libraries, not static ones. That’s a PITA.]

[Update 5:52: Okay, the convenience library thing is upsetting.  The output of what I was working on is a static library and there are same example command line tools that link against it.  From my reading of the cmake stuff, I should just include the library source files to the target for the executables being created.  The problem with this is for n example programs, I’m compiling librets n times.  This doesn’t seem very optimal.]

zsh word splitting

Awhile ago, after I showed him how I indexed my mail with mairix, MARK gave me a zsh function to wrap a call to mairix and then invoke mutt.  For some reason, when using the function, I was never able to pass multiple search terms to mairix and have it return results.  It always failed.

It turns out that this was a zshism that I wasn’t aware of, and Mark might not have been as well.  I finally took the time to get to the bottom of this and I found this FAQ which explains how word splitting differs in zsh.  (All OTHER shells do it wrong, of course.)  In any case, my multiple search terms were being passed to mairix as a single command line argument, so, of course nothing matched.  I edit the script to call mairix ${=*} instead of mairix $* and it works now.

MARK might not have run into this because he might have SH_WORD_SPLIT turned on.  I do not.

Anyway, here’s the function:

mairix_mail (){
  if (( ${#argv} == 0 )); then
    # nothing to do
    mairix --help
  # search
  mairix ${=*}
  # see the results
  # assumes results are in ~/Maildir/search_results
  mutt -f=search_results
alias gm='mairix_mail';