Re: Detecting OS X version from perl

[email protected] (Chris Devers)
Newsgroups perl.macosx
Message-ID <[email protected]>
On Nov 17, 2007, at 7:37 PM, Michael Barto wrote:

> Just a quick question. Is there a command line at a terminal window  
> of MacOSX that can do this- tell you more about the hardware?

Quick report:

     $ system_profiler -detailLevel mini

Obsessive detail report:

     $ system_profiler -detailLevel full

> Also list software packages and their revisions and also patches?

You can get a lot of this from skimming through the /Library/Receipts  
folder, e.g.:

     $ grep -A1 'BundleShortVersion' /Library/Receipts/*.pkg/Contents/ 
version.plist  | grep string

This works better up through Tiger; the package format changed with  
Leopard and there may be a new, better way to access that now (maybe  
run `lsbom` on files under /Library/Receipts, but that doesn't seem to  
have version data).

You can also just query the app directly, modifying the example above,  
as:

     $ grep -A1 'BundleShortVersion' /Applications/*.app/Contents/ 
version.plist  | grep string

Which now that I think about it probably the way to go, as it's  
largely the same data as the Receipts folder, but also includes things  
that don't have an installer (e.g. Firefox, Skype, Adium) and things  
with a third-party installer (Microsoft Office, the Adobe CS suite,  
StuffIt, etc).

  * * * * *

On a different tack, since this thread has come back up, I forget if  
it was mentioned the first time around, but the system version and  
build should always be available from:

     $ cat /System/Library/CoreServices/SystemVersion.plist

This is useful if you ever need to check, say, a remote file server,  
or a machine in Firewire target mode, where you can't query  
system_profiler, sw_vers, etc.

If you do the same for the Finder --

     $ cat /System/Library/CoreServices/Finder.app/Contents/ 
version.plist

-- it may or may not be in step with the SystemVersion (it probably  
would be, but checking the system itself is more direct).


-- 
Chris Devers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.