[MacTUG] Fun with plists
Dani Roloson
daroloso at mfcf.math.uwaterloo.ca
Tue Apr 10 13:33:23 EDT 2012
I was dreading having to do 150 slightly different commands
on 150 machines until I thought of using a plist as a hash.
% defaults write HostUser mac1 Tom
(creates ~/Library/Preferences/HostUser.plist)
% defaults write HostUser mac2 Harry
% defaults write HostUser mac3 Dick
% defaults read HostUser mac3
Dick
% defaults read HostUser
{
mac1 = Tom;
mac2 = Harry;
mac3 = Dick;
}
% scutil --set ComputerName "mac2"
(This will already be set for the machines.)
(Spread the HostUser.plist and the following script to the machines.)
#!/bin/tcsh
set myhost=`scutil --get ComputerName`
echo $myhost
set myuser=`defaults read HostUser $myhost`
echo $myuser
... do whatever with $myuser e.g. create account ...
(Execute the script using UNIX under ARD.)
mac2
Harry
PlistBuddy, part of the Xcode install, is also handy.
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/PlistBuddy.8.html
Dani
More information about the MacTUG
mailing list