Archive for January, 2009

The joy of xargs

I had a situation where I had a directory with about 230 subdirectories, comprising about 900GB. I had a number of 450GB drives I needed to back it up to, and I didn’t want to have to do a 230 different cp commands. Enter xargs. I love xargs. You give it a source of input, and a command to run, and it will run the command, using the supplied input as arguments.

So for my 230 directories, I need to hand a certain number of those directories as an argument to cp. I decided to copy anything starting with a through i to one drive, j through r to another, and s through z to a third. From the source directory, you do this:

ls -d [a-i]* | xargs -J name cp -Rp name /path/to/backup/folder/

The -d flag is important, as that will make ls just return the name of the directory. The [a-i]* will match anything starting with a through i, followed by any number of characters. The -J lets you specify a replacement string. This takes the input supplied via the pipe, and for each line of input (in this case, the name of a directory), runs cp, replacing “name” with, in this case, the name of a folder.

And, of course, -Rp to recursively copy everything in those folders, preserving permissions, special attributes, ACLs, etc.

Leave a Comment

Missing Persons in dslocal

I ran into a Leopard system the other day that was behaving erratically. I looked at system.log, and encountered some errors I’d never run into before.

Jan  6 10:04:42 Edit1 /System/Library/CoreServices/coreservicesd[60]: _scserver_ServerCheckin: client uid validation failure; getpwuid(92) == NULL
Jan  6 10:05:13 Edit1 com.apple.launchd[1] (com.apple.launchd.peruser.92[183]): getpwuid(”92″) failed
Jan  6 10:05:13 Edit1 com.apple.launchd[1] (com.apple.launchd.peruser.92[183]): PID 182 “SFLSharedPrefsTo” has no account to back it! Real/effective/saved UIDs: 92/92/92
Jan  6 10:05:13 Edit1 com.apple.launchd[1] (com.apple.launchd.peruser.92[183]): PID 166 “SecurityAgent” has no account to back it! Real/effective/saved UIDs: 92/92/92

Lots of those, and for various UIDs and myriad processes. I thought I’d open up dscl and see what was up with the system users.

Edit1:~ user$ dscl

Entering interactive mode... (type "help" for commands)

 > cd /Local/Default/users

/Local/Default/dsRecTypeNative:users > ls

daemon

user

root

Apparently, this system had all of 3 local users. This is a bit strange, as any normal Leopard system should have at least 40.

Gene:~ gene$ dscl . -list users | wc

      41      41     378

What had happened, for reasons that I haven’t been able to determine, was the .plists for most of the system users and groups (located in /var/db/dslocal/nodes/Default/) were missing. I put the machine in target mode, grabbed those from a functional Leopard system, and everything was fine.

Leave a Comment

Useful Metaphors

I’m sure I’m not the only Technology Professional who has heard something like this:

I click on the Start, and then the big E, and that’s the Internet.

At this point in the conversation, it will be very difficult to convince Mom/Dad/Grandparent/Whoever that the Internet is anything other than what you get to with the Big E. It’s not Internet Explorer. It’s the Internet.

This is not an insurmountable obstacle. You just need a good metaphor.

Firefox? It’s like a new TV! (Yes, exclamation point. You need to be enthusiastic. Sell it!) You get all the same channels, it’s just got a different name on the front panel, and the remote is still a little different. No, no, it’s still the Internet! I promise! It’s still HBO when you have a new TV, right? Hey, it might even work a little better. You won’t have to reset all your breakers once a week any more to make the TV come back on!

Leave a Comment