Posted on 12-14-2010 06:19 AM
Looking to the Brain Trust for help on this one. I need to know how to determine the version of an application (.app) from a shell script. Apparently my google skills suck. I have been looking all morning and haven't found a command to do it with a shell script. Any help would be appreciated.
Thanks
Paul Austin
Wells Fargo
End User Computing
704 427-0903
Posted on 12-14-2010 06:31 AM
Look at this:
system_profiler SPApplicationsDataType
so for example:
system_profiler SPApplicationsDataType | grep -A3 "Microsoft Word" | awk '/Version/ { print $2 }'
returns an answer of: 11.6.0
I know that isn't very clean but I think you either gotta use this, or spotlight from the command line, and spot light requires the HDs be indexed.
-Tom
Posted on 12-14-2010 06:35 AM
Other option would be to read the Info.plist file in the app package.
However you might have to tweak the script for each app you are trying to
read.
For example, to read the build number of Photoshop CS4, you could use this
as a start:
cat "/Applications/Adobe Photoshop CS4/Adobe Photoshop
CS4.app/Contents/Info.plist | grep -A 1 AdobeBuildNumber
Unfortunately, that output will need a little cleaning up to glean just the
build number.
Tom's method is probably the better method.
Steve Wood
Director of IT
swood at integer.com
The Integer Group | 1999 Bryan St. | Ste. 1700 | Dallas, TX 75201
T 214.758.6813 | F 214.758.6901 | C 940.312.2475
Posted on 12-14-2010 06:35 AM
Is the versioning information gathered in the inventory from a Recon cycle
not sufficient?
Tom's answer looks good, but understanding WHAT you need it for may net an
easier answer...
Craig E
Posted on 12-14-2010 06:40 AM
I usually go digging in the Info.plist myself and grep/cut/awk out the
answer I'm looking for. Unfortunately, a lot of developers don't adhere to
Apple's guidelines and what shows up in the inventory isn't always
accurate. So thus you need to dig in and find it yourself.
j
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436
Posted on 12-14-2010 06:42 AM
Thanks guys.. This is good info. I guess I should have explained what I am
doing in a bit more detail. In my environment I have Restore partitions on
each machine. I am looking to determine what version of Casper Imaging is
on the Restore partition and update it if required. What I was going to
do is capture the casper imaging version and then store it as a dummy
receipt on the System Volume so that the JSS will capture it. Then I can
use other scripts to manage the version of Casper Imaging on the Restore
partition.
Posted on 12-14-2010 06:45 AM
Or you could use Steve's suggestion using the defaults command, which will give you just the version. Below is an example we use to determine the Flash player version, utilizing an extension attribute:
if [ -e "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info.plist" ]; then
version=defaults read "/Library/Internet Plug-Ins/Flash Player.plugin/Contents/Info" CFBundleShortVersionString
else
version="1.0"
fi
echo "<result>$version</result>"
The only thing to note with the defaults command is to not include the .plist extension. So for the Photoshop example:
defaults read "/Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app/Contents/Info" CFBundleVersion
You may also need to look at the Info.plist to determine which key you'll actually want to read. For Photoshop, the CFBundleVersion is nicer than the CFBundleShortVersionString.
Travis
Posted on 12-14-2010 06:49 AM
Great tip Travis! I didn't realize you could do it that way:
defaults read "/Applications/Casper Suite/Casper Imaging.app/Contents/Info"
CFBundleGetInfoString
That will give you the short version of Imaging.
Sweet/sig
Posted on 12-14-2010 06:52 AM
I wouldn't be surprised if recon used system_profiler under the hood anyway.
Another option would be mdfind which utilizes spotlight from the command line. You could also use find command to find the version of each application, however I think I am going to need more information. Even the example code I provided probably wouldn't work on every single App as Jared said, not every developer adheres to Apple's standards.
Posted on 12-14-2010 06:53 AM
This is perfect. I would have not thought about using the defaults command.
Posted on 12-14-2010 07:03 AM
This again, only applies if the developers adhere to Apple's standards.
Posted on 12-14-2010 07:42 AM
Try this:
On 12/14/10 8:19 AM, "Paul.Austin at wellsfargo.com" <Paul.Austin at wellsfargo.com> wrote:
defaults read /path/to/app/Contents/Info CFBundleVersion
--
William Smith
Technical Analyst
Merrill Communications LLC
(651) 632-1492