image
image

|


Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old April 29th, 2008, 06:58 PM
Registered User
 
Join Date: Nov 2005
Posts: 110
Thanks: 1
Thanked 0 Times in 0 Posts
mosx86 is on a distinguished road
cli the OS version?

I'm working on a shell script and need to be able to pull the OS version and the version of Safari in order to do various things...

I can get Safari's version number from the

/Applications/Safari.app/Contents/version.plist file and with some creative sed should be able to finagle just the version number.

For the OS version, using will get me close enough to manipulate:

system_profiler SPSoftwareDataType |grep "System Version"

But I was curious if there was a more obvious and simpler way to do this from the command line.

Thanks!
Reply With Quote
  #2  
Old April 30th, 2008, 12:44 PM
Registered User
 
Join Date: Nov 2005
Posts: 110
Thanks: 1
Thanked 0 Times in 0 Posts
mosx86 is on a distinguished road
Solved

So there are a plethora of ways all better than what I was doing:

Code:
system_profiler -xml SPSoftwareDataType | awk '/os_version/{getline;print $4}'
How to get the version of Mac OS X from the CLI

It seems the less complicated way is:

Code:
sw_vers -productVersion
or

Code:
defaults read /System/Library/CoreServices/SystemVersion ProductVersion
Now to figure out a less complicated way to find the Safari version than what I was using:

Code:
cat /Applications/Safari.app/Contents/version.plist | awk '/CFBundleShortVersionString/{getline;print $1}' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
Defaults can read plist files so lets try this:

Code:
defaults read /Applications/Safari.app/Contents/version CFBundleShortVersionString
Success (but only if you use the full path)!!!
Reply With Quote
  #3  
Old April 30th, 2008, 12:51 PM
Registered User
 
Join Date: Mar 2005
Posts: 191
Thanks: 0
Thanked 1 Time in 1 Post
artov is on a distinguished road
$ sysctl -n kern.osversion

But, the version it gives is a hexnumber: 9C7010 (same as your version has in parentheses), so I am not sure if it helps.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 05:43 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.