Re: Getting processor description from sysctl
Re: Getting processor description from sysctl
- Subject: Re: Getting processor description from sysctl
- From: "Finlay Dobbie" <email@hidden>
- Date: Fri, 16 May 2008 18:29:36 +0100
On Thu, May 15, 2008 at 11:40 PM, Terry Lambert <email@hidden> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden