Re: Getting processor description from sysctl
Re: Getting processor description from sysctl
- Subject: Re: Getting processor description from sysctl
- From: Terry Lambert <email@hidden>
- Date: Thu, 15 May 2008 15:40:13 -0700
On May 15, 2008, at 2:10 PM, Finlay Dobbie wrote:
On Thu, May 15, 2008 at 10:08 PM, Jordan K. Hubbard <email@hidden>
wrote:
On May 15, 2008, at 1:51 PM, Finlay Dobbie wrote:
Is the format of output from commandline utilities guaranteed across
software updates? I'm sure jkh has made statements to the effect
that
they are not :o)
Unless a command-line utility is producing XML or some other format
specifically designed and documented to be "machine readable", then
the
format is essentially whatever we say it is from release to release
and
there are no warrantees expressed or implied. Finlay is correct
and Terry
was over-simplifying things just a bit in that regard.
Ah, but the structure and keys of the output are not documented, and
AFAIK have changed somewhat over the ages.
lsof and ps are documented as producing machine parseable output, if
the appropriate command line arguments are used; for lsof, this is "-
F"; for ps, this is "-o".
"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).
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.
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?
-- Terry
_______________________________________________
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