Re: Getting processor description from sysctl
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=yLP6Qv131/UvS/SYLKVS00Is5a0y35TN1V3MBEMRIDg=; b=jweqR7htWm+i/coj7DYDlFa33HnmMU37o+IszLENw67V3rKGZ4Jvfg5c20HGMRcj21+7nSItHOPq0vb2jMj7jbh6jUQuDwxucBAXa2XXsGPaqNTwbjNNy1DnLEK+U560md6r1cQ5MelUmMfqReB+Jw1jF8bhE2muUtcOSulCAF8= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=a6dwwSU878nqK8sIYm9hIRGs9KqRgeawZAmdlZ21cw93I2MDZ3tnJYih2GBC+T8mrXnTUwLhhNUpBA9cL345F1/AhthxwAnmaqbfBcbTuWVNGXAE7g9ZnfiDwdIiefMqJZtUbMngoS1mMHZ49KJJQteS7khI/Nr0ALJ2ZDDDeRw= On Thu, May 15, 2008 at 11:40 PM, Terry Lambert <tlambert@apple.com> wrote:
"system_profiler -xml" produces XML output; "system_profiler" without -xml is documented as producing colon separated key/value pairs, when queried within a single subhierarchy, which was the specific case under discussion (i.e. also machine parseable for the restricted case being discussed).
Where is this documentation, just out of interest? I don't see any such information in the manpage.
Obviously, if a command doesn't have the necessary options, you are at more risk parsing its output -- but less risk than if you were to (for example) use sysctl-based data interfaces or grovel around in /dev/mem or /dev/kmem, with your code depending on kernel symbols and data structures not changing. They will change.
Of course.
You're right, that one defect of XML is the lack of tool-specific DTDs. You can parse output into an associative array, but you can't guarantee me that a key/value pair isn't going to go away from revision to revision, since there is no DTD to nail me to a cross of immutability. Thus the only thing you can really guarantee me is that the parsing code can be normalized and thus simplified.
So, Finlay, what do you suggest as a more perfect solution to the problem?
In this particular instance, it may very well be the case that parsing the XML output of system_profiler is the best option. My general point was that this is probably more fragile than a supported API would be, and it would be nice if the format of the XML (what keys there are, etc) was documented (like launchd.plist(5) for example) so there was at least some sort of vague nod from the "powers that be" that this is an OK thing to do - because, in general, parsing the output of the tools is regarded as fragile. -- Finlay _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Finlay Dobbie