Firefox - Get Version

New Contributor II

Is there a script to get Firefox versions for inventory or adding to extension attributes


Legendary Contributor III

Why? That should be collected in normal application inventory.

New Contributor II

Yes but it's easier to have a display attribute

Contributor III

Here you go:

if [ -d /Applications/ ] ; then
    RESULT=$( defaults read /Applications/ CFBundleShortVersionString )
    echo "<result>$RESULT</result>"
    echo "<result>Not Installed</result>"

Legendary Contributor III

I get you. I agree it would be a nice feature if we could add a column for any type of inventory item that gets captured to display in the regular columns.

Given that, if you really want a column/Extension Attribute for this, its pretty easy to get just about any application or plugins version information from the Info.plist file inside the <app>.app/Contents/ location.

So something like this for Firefox. Just adjust accordingly for other apps or plug-ins.


FirefoxVersion=$( defaults read /Applications/ CFBundleShortVersionString )

echo "<result>$FirefoxVersion</result>"

Note that although most applications store their version info in the "CFBundleShortVersionString" location in the plist. some store it in just "CFBundleVersion" so you should test any scripts you make for other applications before making them into Extension Attributes.

Also note that the above will just return a blank result if Firefox isn't installed or happens to be in a different location than /Applications/ That can be accounted for, but not sure how much you were looking for here.
Edit: Josh.Smith's script account for that very scenario.

Contributor II

Here is what we use, the benefit to this is that it saves the value as an integer so you can do greater than and less than comparisons.



if [[ -e $ffAppExist ]]; then
    echo "<result>$(/usr/bin/defaults read $ffInfoPlist CFBundleShortVersionString | awk -F. '{print $1"."$2}')</result>"
    echo "<result>0</result>"

Yes, yes I know. The full version of Firefox has three number places. In my opinion I don't care 90% of the time about that. About 90% of the time I am looking at who has the major release versions.The few times I need to know the minor release version I am not relying on the EA to do it.

New Contributor II

Thanks to all for your help , it works fine :)