Kindle Lending Library List

I’m fond of the Kindle Lending Library, but it can be somewhat awkward to use — both returning books and locating books isn’t as simple as one would hope, the process generally being “search for a book and then see if it happens to have a lendable Kindle edition.”  While this is great if I know what book I want, sometimes, I just prefer something free to plow through.  Without further ado and for future reference, this link will show all Kindle Lending Library books and allow the results to be searched through in a sane way:


Fun with Extortionware, or Curse you, Java!

Safety on the internet — that is, protecting your computer from malware — used to be as simple as not downloading and running dodgy executable code.  Sure, some people were tricked, either via emails from “friends” or popups trying really hard to convince them to run a local binary.

Websites that wanted to provide a richer experience had a few options:  run ActiveX controls in IE — the notion of letting a binary run because a website told it to seemed stupid even at the time, even with the idea of “signed” ActiveX controls, so you’d know who provided a control.  There was Flash, a proprietary binary and scripting language now owned by Adobe, and then there was Java, which ran in its own virtual machine with limited access, which seemed like the saner of all the options.

Ransomware Screen

This ransomware screen appeared over pretty much everything

Recently, I stayed in a hotel where the first thing I did was poke through some of my history, looking for an article I’d been reading before — which I located, and about a paragraph in, my screen was entirely replaced with a (fake) FBI warning and a demand to pay a “release fee” of $200 to regain control of my computer.  This was accompanied by the hotel’s IP address, and a display window that was apparently supposed to turn on the PC’s camera and show me in my underwear.

This is known as the “FBI Green Dot Moneypak” scam, or the “FBI Moneypak Virus,” which actually covers a large family of extortionware — which is essentially a monetizing payload, like this scam, plus a way to deliver it to your computer.  In my case, the delivery mechanism appears to be a Java exploit, triggered by either a malicious ad from a site I’d visited before (at home we use a proxy that strips out suspicious ads, so it’s possible it had been there before, but my PC wasn’t actually infected until I visited the same site from the hotel.)

In my case, the infection was completely missed by malware scanners, which seemed to think that my PC was perfectly fine, and even ad hoc scanners proved relatively useless — even a few which claimed to be able to detect and remove this (detection is free, removal requires payment) were blissfully unaware that the infection had taken place.  Googling wasn’t a lot of help either, since I was either directed to sites with generic instructions to run whatever scanner they were hocking (none of which worked) or long lists of registry keys to check, none of which appeared to exist on my system.  So it was either hiding itself well, or too recent to be picked up by scan-based systems.

At any rate, since it was Windows 7, I was able to “switch user” to an Administrator account, and I since I hadn’t received a request to escalate permissions, chances were relatively good it hadn’t inserted itself too deeply into my OS.  I found two suspicious binaries — suspicious, because they weren’t where binaries typically go:  in c:\ProgramData was “lsass.exe” and in c:\Users\username\AppData\Local\Temp was “ctfmon.exe.”  Both of these are legitimate Windows binaries that would be run — lsass.exe, for example, is the Local Security Authority Subsystem Service, a legitimate version pretty much needs to be running or the system will restart, and ctfmon.exe activates the language bar.  Since I generally have that turned off, this is pretty suspicious, but even more suspicious is the location of these files.  Deleting them in safe mode (from an alternative account) cleared the infection, returning control of my PC.  The PC complained about not being able to find a few files it wanted to run on startup, but I considered that a good sign.

Meanwhile, I went back to my browser to examine the source of the infection, and surely enough, a Java plugin was enabled — and since it’s the only thing enabled, it’s pretty obvious that this was the source of the problem.

If you haven’t done so already, I’d recommend disabling your Java plugins (virtually no Internet site uses it any more) and any other plugins which you don’t actually need.  If you do use Flash, which is relatively hard to avoid, at least make sure it’s up to date.  Note that updating the version of Flash doesn’t necessarily update the plugin version, so check from within your browser, not just by looking at versions in the Control Panel.

Mozilla has a handy URL that actually works across browsers:



[not over] Packing for Travel

I recently stood in the airport security line, watching the passenger in front of me struggle with wangling his things into five bins, awkwardly shoving those plus a rollerboard and duffel bag down the belt.  “How long are you going for?” I asked.

“Oh, just the one night,” he said, noticing my one backpack and one bin (for the laptop. ) “Did you check your bags?”

“Heavens no, I’m only going for four days.”

As one who travels frequently, and has for a while, I make it a rule not to carry more than one bag unless I really need to, and with rare exceptions, I never do.  I realize some people may have medical conditions that force them to travel with special shampoo or dozens of shoes, or can’t lift enough to carry around a bag without wheels, but in my observation, people carry around a lot more than they actually need to.

I recently went through my travel kits and shed about a pound of stuff that is becoming less necessary:  an ethernet cable, a VGA cable, a few audio cables.  I’ve added a DVI cable to what I carry — it seems that hotel televisions will either accept this input (sometimes with a little fiddling) or be so antiquated or locked down that no connection is possible.

I do follow a few simple rules to keep things efficient:

  • Every cable is retractable.  This eliminates tangles and clutter, making packing quicker as well as reducing bulk
  • Everything but clothes in kits.  This serves a few purposes:  it’s easy to find things and tell if something’s missing in a small kit, and each kit serves a specific purpose.  So if I know I’m going to a country with non-US power, I can grab that kit, and I can leave the airplane power kit at home if I know the airplane doesn’t have power outlets (or it’s a short flight.)  It also keeps all the stuff from rubbing on each other.  I use colorful Guatemalan bags for each group of things.Kits
  • Check the weather.  While no forecast is perfectly accurate, it’s senseless to pack everything from a short-sleeved shirt to a parka “just in case.”
  • Stop carrying anything you don’t use.  I periodically go through everything I carry, and if it went on a trip with me and I didn’t use it, it’s probably not going next time.  (There are a few things that are handy to have and compact, like a lens cleaning cloth, that survive the purge, but not many.)
  • Clothes get rolled or bundled.
  • Don’t carry things the hotel has.  If there’s any doubt, it’s worth confirming, but carrying around a hair dryer or iron is pretty ridiculous for most destinations.  I’m usually fine with hotel soaps and shampoos, and carry a small amount of paper shampoo just in case.
  • As few devices as possible.  This is getting easier and easier, as one smart phone can eliminate almost everything else, but I still see people traveling with phones, mp3 players, laptops, DVD players, e-readers, tablets, hand held games, those massive Bose headphones, piles of media and god knows what else.
  • Devices that are as small as possible.  I’ll bring up the massive Bose headphones again — don’t get me wrong, they’re very nice, but they’re a lot to carry around.  Personally I take noise-canceling earbuds, which fit in a shirt pocket.  Laptops are a touchy subject, but there’s little reason to lug around a huge screen if you can plug it into one when you need it, and I’ve seen more than one person struggle with a laptop so large it couldn’t reasonably be opened in the space allowed by a plane seat.
  • Both hands empty.  This has a lot of implications, but essentially, if you have to carry something in your hands, it’s something you have to put down to use your hands, or learn to juggle.  If you’ve ever seen somebody carrying a bag in each hand take a phone call, you know exactly what I mean.  It’s one of the many reasons I prefer a backpack to a bag with rollers.
  • Use the “three things” rule.  People can generally keep track of a grand total of three things at a time, so (for example) it’s best not to have more than three things at a time out from your bag on the plane.  Kits are helpful here, since remembering three kits is three things, and you can check to make sure your kits contain the items they should without losing track of a long list of things.  (My memory is quite good, but I have better things to expend mental effort on than keeping track of a larger number of things.)

The breach that keeps on giving

In what should be old news by now, back in June, LinkedIn‘s servers were breached, leaking around 6.5 million user names and passwords.  Hackers were then able to determine (for the most part) what passwords were associated with the hashes and accounts.  While this may have compromised LinkedIn accounts, the greater problem is with any other accounts that happen to use the same username and password.

In my case, the only such pair was LinkedIn and, which was a bit sloppy on my part, but since I’m not in the habit of re-using passwords at all, it hadn’t occurred to me, nor had it occurred to me that this would present a problem until somebody managed to send an express package from the Ukraine, charging my account for it, to the tune of $60 or so.

While I’m kicking myself for this, it could have been a lot worse, even if I were to use the same password for email, which would then have allowed hackers to intercept “lost password” requests for all the accounts I have which don’t use the same passwords.

The lesson I take away is that even accounts I consider “unimportant” because they’re not linked to credit cards or can be used to make purchases should be given random passwords rather than common, disposable passwords.  And, of course, chaining accounts is bad.




FreeBSD bsdpan- to p5- migration for perl modules

FreeBSD has a package system to manage installations and dependencies, and so does perl.  Perl on FreeBSD, therefore, causes these to intersect in interesting, and sometimes suboptimal ways.

CPAN can be used to install perl packages that aren’t in the ports tree, and FreeBSD handles this with relative grace by including them in its package database with the prefix “bsdpan,” and be excluded from updates.  An identical package installed from the ports tree will be prefixed with “p5” instead, and be treated as any other port, with dependencies and upgrades handled as part of the ports system.

After trying out a few CPAN modules (which in turn installed their own dependencies) I found myself with a great many “bsdpan” packages, which I’d prefer to tuck neatly into the bsd ports tree rather than continue to manage with CPAN, therefore, I whanged together a shell script to do it:

pkg_info | grep ^bsdpan | awk '{print $1}' > /tmp/bsdpan-to-p5.tmp
> /tmp/bsdpan-to-p5-2.tmp
cd /usr/ports
while read bsdname; do
  name=$(echo $bsdname | cut -c 8- )
  portpath=$(make search name=p5-$name | grep ^Path | awk '{print $2}' | sed -r 's/\/usr\/ports\///')
  shortname=$(echo $name | sed -r 's/(.*)-.*/\1/');
  if [ "$portpath" ]; then
     echo -n p5-$name is in ports,
       echo " adding to list"
       echo portupgrade -o $portpath -f bsdpan-$shortname >> /tmp/bsdpan-to-p5-2.tmp
     echo p5-$name not in ports
     portpath=$(make search name=p5-$shortname- | grep ^Path | awk '{print $2}' | sed -r 's/\/usr\/ports\///')
     if [ "$portpath" ]; then
       paths=$(echo $portpath | wc -w)
       if [ "$paths" -eq "1" ]; then
          p5name=$(make search name=p5-$shortname- | grep Port | awk '{print $2}')
          echo " ... $p5name found, using that"
          echo portupgrade -o $portpath -f bsdpan-$shortname >> /tmp/bsdpan-to-p5-2.tmp
done < /tmp/bsdpan-to-p5.tmp
rm /tmp/bsdpan-to-p5.tmp
echo "Starting conversion ..."
sh /tmp/bsdpan-to-p5-2.tmp
rm /tmp/bsdpan-to-p5-2.tmp

The script tries to automate a manual process of finding the corresponding “p5” port for each “bsdpan” port, and builds a script that replaces each one using the portupgrade tool.

It doesn’t make any attempt to resolve dependencies, so it may take a few passes.  It also can’t help where a search for the port name returns more than one possibility (usually part of a longer name) or when the “p5” name happens to be nothing like the “bsdpan” name, but in practice, there are only a handful of exceptions.


3D Printing — A Comedy of Errors

Printing a Proper Raft on a Makerbot Thing-O-Matic

Printing a Proper Raft on a Makerbot Thing-O-Matic

I recently acquired a Makerbot Thing-O-Matic, a printer I selected due to its apparent ubiquity and to its price — under $1000 if you do the assembly yourself.  With the heady optimism and overconfidence borne of having not yet attempted something, I dove in with my boxes of parts and wiki instructions.  Besides, I build stuff all the time, which is the point of having a 3D printer in the first place.

Another appeal of a largely community-supported machine is the lack of need to talk to tech support, which is usually a dismal experience.  I contacted a tech support for a popular anti-virus program which would occasionally inexplicably shut down when I was using it on public networks.  Tech support’s answer: don’t use public networks.

At any rate, aside from backtracking a few times (the combination of extra parts and following some outdated instructions led to a few false starts, and a quirk or two of design, assembling the little beast wasn’t a problem.  I didn’t start causing my own problems until I actually started printing.

I calibrated and made little adjustments in order to improve my print quality:

  • The stepper extruder didn’t have enough clearance to grip the filament, so I removed a washer
  • The extruder had trouble pushing the plastic through, so I increased the temperature
  • The raft was blobby, so I lowered the nozzle relative to the build platform
  • The raft didn’t stick to the build platform, so I raised the temperature of the build platform

After all this tweaking and adjusting, I was able to print some pretty good looking calibration cubes, that more or less looked like the pictures I was seeing on the web.  However, absolutely all of these adjustments were exactly the wrong thing to do.  I had managed to put together a set of tweaks that made fairly good, accurate prints, that warped crazily as soon as they were finished.

  • The stepper extruder doesn’t have much clearance for the filament because it grips the filament very tightly.  The filament should have bite marks from the extruder.  Putting the washer back in, I cut the filament in a “v” shape before feeding it in so that it could be gripped.
  • Turns out I could actually lower the temperature of the extruder, now not having any trouble pushing filament through the nozzle.
  • Having the nozzle so close to the build platform was pressing the raft right into whatever I was printing.  Raising the nozzle opened up the raft and allowed it to actually come off.
  • With the nozzle farther away from the build platform, it no longer tended to drag the plastic away from the platform, and the platform temperature could be lowered as well.

Weirdly, even with things boldly out of whack, I was able to produce some very good prints, although they took a lot of clean-up and sanding, and warping was a real issue.  The look of things hasn’t changed much, but less clean-up is necessary and less warping means more things will actually come out shaped closer to how they were designed.


A Brief Tale of ATM Ripoff and Redemption

I’ve become a bigger fan of than ever.  Even though it has a few minor flaws, it provides an excellent dashboard to see current and pending transactions to all accounts at once.

I’m not compulsive about checking my accounts, but I find its phone app handy to check occasionally to plan or check spending, which is where I noticed an unusual withdrawal from my account, from an ATM, for $167.36.  I don’t have a debit card, so this struck me as a fairly unusual amount to withdraw from an ATM, and I made a mental note to follow up as soon as my plane landed.

When I did, I made two additional discoveries:

  1. The ATM withdrawals had been made from Bogotá, Colombia
  2. Enough withdrawals had been made to completely drain my modest checking account

It’s worth pointing out that my ATM card was safely in my wallet, and I’d never given my pin out to anybody.  Nor had I used any dodgy teller machines — I’d like to think I’d notice a skimming device, but they can be fairly sophisticated — at any rate, I do keep an eye out for such things on general principal.

A google consensus links fraudulent withdrawals from Bogotá specifically to compromised ATM’s in La Antigua, Guatemala…  Where six months earlier, I’d spent a month.  At the time, I had been diligent about checking for unusual withdrawals or activity, and it had all been legitimate at the time, and for six months after.  (Articles describing the linkage are here, and here, among other places.)

There’s some rampant speculation in those articles, but I do know enough about ATM communication to know that no ATM uses “unencrypted communications.”  That said, through complicity, skimming, or compromised ATM software, both my card number and PIN were acquired and transmitted to Colombia, where six months later, a copy of my card was used to drain my account.

My bank was relatively helpful, first canceling my ATM card, and saying that they “would investigate.”  I waited a few days and called for more details — and I’m very glad I did, since I needed to fill out an affidavit and get it notarized.  I was gratified by some of its language:

“I fully realize that [this affidavit] may cause the arrest of a person or persons for the unauthorized use of Credit/Debit card identified in paragraph 1 above…”

I should certainly hope so.

I was also informed that the notarized affidavit needed to be in their possession within 10 days or the money could not be refunded.  Nice to know!  I, for one, would hate to lose a bunch of money because a clock ran out that I didn’t even know was running.  (10 days seems like an insanely short amount of time, given that bank statements are usually issued monthly.  I was given a vague reason about “Visa regulations,” which is slightly odd since it’s an ATM card, not a debit card, and I don’t know of any ties to Visa, but I’m not about to argue the point since I actually can get the paperwork back to them that quickly.)

I supposed I can relax a bit since the money is [provisionally] back in my account, but I’d feel even better if I knew that a group of culpable Colombians and Guatemalans were rotting in a jail cell right now.


On Running the Hell Away

In the 80s, I worked for an economic consulting firm and defense contractor in the heart of Washington, DC.  We had just landed an important contract in Ohio, and I had been assigned as the systems architect — I would need to move.  Invoking the transfer clause in my lease, I terminated the lease in my apartment, moved all my stuff into my car, and prepared to move to Ohio.  However, this left me a few days without an apartment working in the old office before I was supposed to report to the office in Ohio.

A friend offered his couch for a few days, except he wouldn’t be back in town until Friday night, and it was Thursday.  No problem, one night in a hotel wouldn’t be so bad.  Except, not having a lot of money, I figured one night without paying for a hotel would be even better, and hit upon the brilliant idea of spending the night at the office.

Figuring it was better to ask forgiveness than to ask permission and get denied, I thought I’d just avoid getting caught.  People must work late all the time, so surely it couldn’t be that bad if I did get caught.  At worst, I might get fired and not have to move to Ohio, I thought.  I was wrong about that.

Not wanting to prolong the experience, I had a long dinner, and showed up at the office around 10:00 p.m.  It was a large office, and the doors were all badged with access cards, except for a small, unmarked side door that took an actual, physical key.  Months earlier, I’d been handed the key by the manager of the server room to make it easier to move equipment, and I’d neglected to give it back — quite innocently — but now I wouldn’t have to explain why my card showed up on the entry records so late at night.  We did do defense work, after all, and I didn’t want to be mistaken for a spy.

Opening the door quietly, I snuck past the server room and froze, as I saw the beam of a flashlight dancing at the end of the hall.  My access card may or may not get me into the server room at this hour, but that would be a lot to explain.  I flattened against the wall in a side hall and waited.

The security guard didn’t shine his flashlight down the little dead end I’d stuck myself in, and continued on his way.  I figured the safest thing to do would be to go the other way, which would take me away from my cube, where I had originally been headed.  While it might be easier to explain why I was sleeping at my own cube at two in the morning, it hardly seemed comfortable, so I headed past the main reception desk.

It was a big glass desk, too open and visible, for my purposes.  On the desk there was an etched crystal globe about the size of a baseball which I liked, so I picked it up as a talisman, intending to return it at the end of the night.  (At least I was only sort of wrong about that.)

Hearing footsteps from the direction in which the guard went, I left the reception area and ran into the media room just behind it, a large room used for presentations and for impressing guests.  I dove and slid quietly across the marble floor under a “history table” that held various awards and stacks of brochures about our company.  The table was a lot shallower than I’d hoped.  I envisioned the guard’s flashlight beam settling on my backside and my halting attempt to explain just what the hell I was doing there.

Footsteps stopped at the door and I watched the wall light up as a beam scanned the room — it didn’t get below desk height — he clearly wasn’t looking for some idiot hiding under a table.  The footsteps moved on, and I breathed a sigh of relief.

One hall connected to the media room led to “mahogany row,” which wasn’t actually mahogany at all, but referred to a set of nicely appointed offices used by the company higher-ups.  Perfect, I thought, one of them probably has a couch, and maybe even a bathroom.  The hall looped around the front of the office to the reception area, so I wouldn’t be trapped, either.

Unfortunately, it hadn’t occurred to me that most of these offices would be locked with access cards.  I walked down the dark hallway, gently pushing a few doors experimentally, but of course they were all locked — some of our work was classified, after all, and not all of it went to the vault every night.  I got to the corner office — and couldn’t believe my luck — the door stood open about a hand’s width.  I couldn’t see much in the gloom, but I pushed the door open as quietly as I could.

This was Phil’s office, a company vice president.  We’d talked a couple of times, but were too far apart on the food chain to take much notice of each other, much less for me to spend any time in his office.  His windows were huge, and let enough light in for my dark-adjusted eyes to see more than grey outlines.

My heart jumped — there was clearly a man sitting on the floor, not moving.  I followed the man’s gaze to see Phil hanging from his neck from the ceiling behind his desk, his teal tie apparently tied into a noose.  The man on the floor stood up very slowly, and I saw that he was looking straight at me.  He looked classically Russian;  He was a short man, perhaps 5’2″, white, cold blue eyes, and no emotions in his facial expression.  In his gloved hand there was a gun, and he was raising it toward me.

My brain “unstuck” and I felt an adrenalin surge, and good advice sprung to my head, unbidden.  Your priority is to get away.  Then, act, before they think you will.  I threw the globe as hard as I could at the man.  At the same time, I yelled.  At this point, all concerns about evading the security guard melted away — better to be caught and fired than dead.

I should have turned away and just bolted, but I didn’t resist the urge to see where the globe landed.  I had aimed at his head (another mistake, I should have aimed for the center of his body) and he tilted his head slightly away from its path, not taking his eyes off me for a moment.  The globe crashed into the wall behind him, making a hole and sending up a small cloud of plaster dust.  Why are you still here? my brain screamed.

I felt a hand on my shoulder.

I twisted away and down, heading back around toward the reception area, looking only in front of me, and ran.  The hallway turned sharply, and I looked back again as I turned, to see the security guard crumpled and the small man stepping over him.  (Had I heard a gunshot?  I don’t think so, but my heartbeat is loud in my ears.)

In high school, I briefly held the school record for the 100 meter dash, of which I was fairly proud and considered joining the track team.  (The next day, my record was shattered by a boy who ran in cowboy boots and who later was selected as an alternate for the Olympics, but that’s beside the point.)  As long as I didn’t do anything stupid, that is.

During my brief high-school football career as a wide receiver, I intercepted a pass at the 1 yard line and ran down the field.  As I neared the opposite side of the field, I had a horrifying thought:  was I running the wrong way?  Was anybody chasing me?  I imagined both teams standing at the other end of the field, watching me in disbelief as I did something idiotic in front of thousands of people.  I slowed down a little and looked back … only to be flattened by the other team.  I had run an interception 97 yards and not made a touchdown.

My fellow team members called me “Almost” after that.

I wasn’t going to make that mistake again.  I didn’t stop, slow down, or look back as I vaulted down 5 flights of steps and ran down K street.  Downtown Washington DC is pretty deserted late at night, so there wasn’t a lot to slow me down.  After a few blocks, I stopped running in a straight line and random right and left turns until I was thoroughly exhausted.

At a gas station pay phone (yes, there were such things back then) I called the police.  Not wanting to go back to my car or the office, I took a cab to Alexandria and paid for a hotel.

The next day, I went to the office as usual, expecting quite a scene, but oddly — it was business as usual.  No police tape, no office buzz, nothing.  The globe was back at the reception desk, but was whitish over Eurasia with ground in plaster dust.  I detoured through the media room and looked down (now well-lit) mahogany row — every office was open except Phil’s.  Closed, but not barricaded or guarded.

Nothing seemed out of the ordinary, and I didn’t dare ask.


Zebra/Eltron/UPS 2844 label printing with

Labels are both more convenient and professional-looking than plain paper for printing postage labels, and the 2844 is a great little thermal workhorse of a printer.  Even better, it’s pretty cheap to pick up a used one, partly because UPS gave these away for free for use exclusively with the UPS service.

On the down side, if you do pick up a used one, it’s probably not going to be quite as easy as just plugging it in and hitting print.  (In particular, it took me a while to sort out why it was printing a blank label for every label it printed, which was surprisingly tricky to fix.)

First, update the firmware by navigating here and selecting “TLP 2844.”  You’ll need the ZDownloader and the latest standard firmware.

Pick up Windows drivers and setup utilities from the same page, under “drivers.”  Note:  if you have a USB model, you might need to guess what virtual USB port your printer is configured on, which may take a few tries.  Mine was on “USB002.”

Go ahead and load 4×6 label stock, then load up the Zebra Setup Utilities, and select Tools->Action>Calibrate Media.  This will scroll through a bunch of labels, but you should only have to do this once.

Also in Zebra Setup Utilities, go to configure printer settings, and set the label size to 4×6.  The defaults should be fine for everything else.

At this point, you should have a Windows printer called “ZDesigner LP 2844,” which is exactly what you want.  You can use it at this point, but it will print out extra labels when used with

To correct that, right-click on the printer to open properties, then on the General tab, select “Printing Preferences.”  On the “Options” tab, make sure that the setting for “Stocks” matches your label size (if not, go back and set up the stock.)  Then go to the “Advanced Setup” tab, and make sure that double-buffering is on.

LP2844 Miscellaneous Advanced SettingsOnce in the software, “printing on” can be set to “Zebra/Eltron Type – Standard 4×6 label – roll” and then selecting “ZDesigner LP 2844” as the destination.  Of course, I recommend using “print sample” first, to make sure that everything is dark enough and aligned properly before printing actual postage.



Green backups with BackupPC and WOL

In an effort to reduce power consumption, I’ve moved most systems I use regularly onto a pair of virtual servers, enabling me to keep many machines off most of the time, except for occasional use.  There are still a few physical machines, and I do prefer to have current backups of everything, so I decided to use the wake-on-LAN protocol, which seems to work for most modern computers hard-wired to ethernet (on the same segment.)

I started with this post by Salik Rafiq, but my first problem was that I didn’t want to turn every machine on, back it up, and then just leave it on.  Nor did I particularly want to turn every machine off after being backed up, since it’s not unusual for a machine to be backed up while I’m actually using it for something.  The obvious solution is to store whether or not a machine is actually on, then return it to that state afterward.

I made a few other changes, which I’ll briefly outline:

  • My BackupPC sends 5 arguments to ping, so I lazily hacked in arguments 3 and 4.  (There are much more elegant ways to do this.) so this script assumes that the last argument is the machine name.
  • I replaced “ethwake” with “wakeonlan,” for the sake of simplicity (not that etherwake doesn’t work, but since WOL packets require a hardware address anyway, why not just use the hardware address?)
  • Related to the above, I retrieve and store the hardware addresses for each machine using the simple command “arp -a machine > machine.wol” which gives me a file with the hardware address for each machine.
  • Note that I use the hardcoded directory “/usr/tools/wol” for both hardware and state information.  The $WOLDIR directory is used for hardware and state information.

As with Salik’s original script, this replaces the “ping” command for BackupPC, and is reasonable to use with every machine, whether or not it supports wake-on-lan.


#this script is totally designed for the backuppc ping command
#which is the first thing it does before it starts a backup
#this is a substitute which pings the machine, if it is not
#awake then it wakes it using a magic packet - using the wol.bsh script
#then pings again to make sure


logger "Backuppc pinging $ARGS $WAKEHOST"

function getwol {
	if [ -f $WOLDIR/$1.wol ]; then
	   hwaddr=$(cat $WOLDIR/$1.wol | cut -d" " -f4)
	   logger "No MAC address for $1"
	   exit -1

function fwol {
	getwol $1
        sudo $ETHWAKE $hwaddr

$PING $ARGS $WAKEHOST >>/dev/null 2>&1

if [ $? -ne 0 ]; then
        fwol $WAKEHOST
        if [ "$WOL_RES" = "FAIL" ]; then
                exit 1
	echo "OFF" > $WOLDIR/$WAKEHOST.state
        sleep $SLEEPTIME
        if [ $? -eq 0 ]
           logger "success waking $WAKEHOST."
           logger "unable to wake $WAKEHOST."
           exit 1
   echo "ON" > $WOLDIR/$WAKEHOST.state

exit 0

To turn the machines back on, I updated my script (see this post for details) to look up the machine state, and if it was off before, turn it off now:

PID=$($WINEXE -U $UNAME -W $WRKGRP --password=$PWD //$BOX 'cmd /c echo '1'
> c:\backuppc\wake.up')
echo "Rsync and shadow copy unloaded"
if [ -f /usr/tools/wol/$BOX.state ]; then
   read wasoff < /usr/tools/wol/$BOX.state
   if [ "$wasoff" = "OFF" ]; then
      $WINEXE -U $UNAME --password=$PWD //$BOX 'shutdown -f -s -c "Backup

Although it only recognizes “on” and “off” as valid machine states (it doesn’t detect nor return a system to hibernated, sleeping, etc. states) it at least takes care of the simple function of turning machines on, backing them up, then turning them back off.

For systems that don’t support wake-on-lan, like those connected through wireless, I’m considering using X10.