maanantaina, elokuuta 31, 2009

Come again?

From HP's customer service web site:
Note: You must have administrative privileges on your Mac computer to install the software. Click System Preferences, Accounts, and check Allow user to administer this computer.
Now let me get this straight: You should grant your account administrative access in order to install some software. But you need administrative access to grant administrative access, don't you, so why bother?

sunnuntaina, elokuuta 23, 2009

Learning XPath

Many of the Mac OS X command line utilities have a -plist option, which makes the utility do its thing in the "plist xml" format. I had the idea that maybe it would a good idea to use it and then use some of the xml tools to extract the information I want, instead of the usual pipeline of grep, awk and sed commands.

Specifically, I wanted to find out the mount point of a file system. I know the device file of the disk partition/slice.

I could try the mount command, but if the mount point directory has whitespace characters, parsing the output of the mount command is a bit fragile.

diskutil info is an OS X specific command that gives me what I want. After learning about XPath a bit, I came up with something like this:

diskutil info -plist /dev/disk0s2 | xpath "//string[preceding-sibling::key[1]='VolumeName']"
This is not yet perfect. The volume name is surrounded by <string> and </string> but I can live with that. The final insight for the XPath expression came from this post.

P.S. This post was written in Blogger's rich text editor in the Safari browser. This was the first time it worked well enough to be useful.