Scripting Mac OS X
Subject:   Defaults Tips & Tricks
Date:   2003-11-10 15:49:22
From:   anonymous2
Just read your O' Reilly article, good stuff! I have one comment. One thing I learned from my last rev of LoginWindow Manager is that its probably best to use the system-domain loginwindow pref instead of root's:

sudo defaults xxx /Library/Preferences/

instead of

sudo defaults xxx

It doesn't really matter which you use, but the /Library/Preferences item is easier to get to from a GUI and just seems like "the right thing to do". Incidentally, you can use the defaults command to read/write just about any xml file, whether its in the defaults path or not:

[anonymous:~] defaults read /System/Library/CoreServices/SystemVersion
ProductBuildVersion = 7B85;
ProductCopyright = "Apple Computer, Inc. 1983-2003";
ProductName = "Mac OS X";
ProductUserVisibleVersion = "10.3";
ProductVersion = "10.3";
[anonymous:~] defaults read /System/Library/CoreServices/SystemVersion

And you can even use it to manage ByHost items that are, for
example, in a user template folder:

sudo defaults -currentHost write
idleTime 300

And that's really nice because it allows you to avoid dealing with the actual name of the file. Pretty damn cool!