I've long been successfully using this hack I found at macosxhints.com:

/usr/bin/awk '/ComputerName/ {{{getline} print substr($0,12,length($0)-20)} exit}' /Library/Preferences/SystemConfiguration/preferences.plist

The output of this command can of course be parsed by Python.

A better way would be to use plistlib to parse the preferences.plist file, but I just never
got around to it since the awk thing has been working reliably.


Brad Allen

IT Desktop Support

[EMAIL PROTECTED]

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to