John,
As Thomas Larkin pointed out, Casper is already doing this with Recon and
reporting back to the main database (which should be running every week or
so by default), and you can use this for inventory and smart groups, you'll
find it in the Smart Group (or Advanced Search Criteria section), in the
Software Information section, then you can use a combination of Application
Title and Application Version to make a group/report on what you want...
Also, CFBundleShortVersionString is what you want to get for version number.
If you get CFBundleGetInfoString it is littered with copyright symbols and
other stuff that would make it hard to use the 'is/is not/like/not like'
criteria on it.
However I've been looking for the opportunity to share some code :)
I made an EA template, copy and paste and past into a text editor save it
with a name ending in .xml in:
/Library/Tomcat/webapps/ROOT/WEB-INF/xml/extensionAttributeTemplates/
If it's world readable I think it'll work, but I like keeping things neat so
it should also be owned by user _appserver and group _appserveradmin
If you don't want to go that far and this is a one off, just copy everything
in the <scriptContentsMac> tags and never mind about making it a template,
just put the app's path in the APPPATH variable. (I did because I made one
for Receipt Versions, which this is based off of, I'll include that too).
You may or may not want it to return a value if it can't find the
Info.plist, or if it finds it, the key may not exist and you may want to
return a value besides 'null' (FYI: JAMF has told me they recommend, because
blank value will match for 'is not', you can get around this by adding a
'not like' and leaving it empty, or having another criteria to match as
well)
Anyway on with the code:
###################
#Get Info String.xml
###################
<?xml version="1.0" encoding="UTF-8"?>
<extensionAttribute>
<displayName>Get Info String</displayName>
<displayInCategory>System Information</displayInCategory>
<dataType>string</dataType>
<description>This attribute reports the value of CFBundleGetInfoString
from the specified Application path's Contents/Info.plist</description>
<scriptContentsMac>#!/bin/bash
APPPATH="EditFromTemplate_Desired_Value_-Example:/Applications/iTunes.app"
if [ -e "$APPPATH/Contents/Info.plist" ]; then
result=$(defaults read "$APPPATH/Contents/Info" CFBundleGetInfoString
2>/dev/null);
else
result="Not Found"
fi
echo "<result>$result</result>"
</scriptContentsMac>
</extensionAttribute>
######
And to share if anyone thinks that not only getting the names of receipts on
the system is useful BUT ALSO THE VERSIONS is important (as I do!) let JAMF
know you'd like this to be a feature in the future, because Frameworks,
printers drivers, and many other aspects of installed software are not as
easily ascertained, either its too "noisy" when collecting Application
versions and plugins (a dev can have multiple Flash Player plugins that trip
up the system), or just certain things aren't reported on (printer drivers,
etc...). I think getting the receipt version does this elegantly and nicely.
Note this is best used in conjunction with "Packages Installed By
Installer.app/SWU" and the bundle name because I prefer to have nothing
returned if the receipt is not found....
#####################
#Receipt Version.xml
#####################
<?xml version="1.0" encoding="UTF-8"?>
<extensionAttribute>
<displayName>Receipt Version</displayName>
<displayInCategory>Software Updates</displayInCategory>
<dataType>string</dataType>
<description>This attribute displays the value of the specified bundle's
receipt value on the client computer</description>
<scriptContentsMac>#!/bin/bash
BUNDLEID="EditFromTemplate_Desired_Value_-_Example:_com.pkg.sts.Office2008"
if [ -e /var/db/receipts/$BUNDLEID.plist ]; then
result=$(defaults read /var/db/receipts/$BUNDLEID PackageVersion
2>/dev/null);
else
#otherwise use pkg_util, only 10.6 reports on non apple packages and is
slow
result=$(pkgutil --pkg-info $BUNDLEID 2>/dev/null | grep version | awk
{'print $2'});
fi
echo "<result>$result</result>"
</scriptContentsMac>
</extensionAttribute>
--
Joel Bruner
Creative Technology Specialist
Y&R Brands
233 N. Michigan Ave. Ste 1500
Chicago, IL 60601
Mac Helpdesk: 312-596-2757
Direct: 312-596-2747
