Posted on 04-25-2014 10:29 AM
I create the fallowing script to use as an Extension Attribute
if [ -d /Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app ] ; then
/usr/bin/defaults read /Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app/Contents/Info CFBundleShortVersionString
else
printf "%s
" "CS4 is not installed"
fi
if [ -d /Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app ] ; then
/usr/bin/defaults read /Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/Info CFBundleShortVersionString
else
printf "%s
" "CS6 is not installed"
fi
exit 0
When I run it on my Mac it shows me the version number for all version of Photoshop on my Mac.
When I run it as an Extension Attribute no results show up in the inventory report.
How can I get the script to show results in in JSS Casper EA?
Posted on 04-25-2014 10:46 AM
You have to wrap your printf statements in <result></result> tags in order for them to be recognized by the JSS and stored in EA's.
Also, "Resluts". Ha!
Posted on 04-25-2014 10:47 AM
There are probably 2 dozen different threads here with examples of how Extension Attributes need to be set up, and that's not counting the built in ones from the template you can add in your JSS, and then examine them. Just sayin'
Surround the results in the following tags by echoing it out as follows-
echo "<result>$your_result_variable_here</result>"
That said, can I ask why you'd be capturing something like the Adobe Photoshop version in an Extension Attribute? That's a built in function of the product. Why reinvent this?
Posted on 04-25-2014 11:06 AM
Well it is nice to have it in a an inventory report.
Thanks I will try this
Is the script should be
"<result>$printf "%s
"</result>"
Posted on 04-25-2014 12:30 PM
OK, I can see what you mean about being able to pull that into a report.
So that should probably be:
echo "<result>$(printf "%s
" "CS4 is not installed")</result>"
Modify the string being echoed in the second one in the script as needed.
Posted on 04-25-2014 12:44 PM
I added the code to the script and change CS4 to the version each line
echo "<result>$(printf "%s
" "CS4 is not installed")</result>"
The results show only "printf %sn CS3 is not installed"
When run manually on my mac I get
11.0.2
<result>CS5 is not installed</result>
<result>CS5.1 is not installed</result>
13.0.6
Posted on 04-25-2014 12:52 PM
It sounds like you want a multi line result, showing what is and isn't installed as well as the version number of what is installed? If so, you need a more advanced script, probably one that builds a bash array and then uses that as the result. You can only do one echo "<result>some result</result>" line in an EA. Trying to echo it multiple times will just end up showing you the final one and not any previous ones.
Posted on 04-25-2014 12:53 PM
Thanks for letting me know. What I am trying to do is find out what versions of Photoshop is installed on Macs. I do not need to see if a version is not installed
Posted on 04-25-2014 01:05 PM
So in the end, you only want a single result in the output, based on what version is installed, or if its not installed?
Posted on 04-25-2014 01:32 PM
I want a multiple result with out showing not installed.
I could do this #!/bin/sh
if [ -d /Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app ] ; then
RESULT=$( defaults read /Applications/Adobe Photoshop CS4/Adobe Photoshop CS4.app/Contents/Info CFBundleShortVersionString )
echo "<result>$RESULT</result>"
elif [ -d /Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app ] ; then
RESULT=$( defaults read /Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/Info CFBundleShortVersionString )
echo "<result>$RESULT</result>"
else
echo "<result>Not Installed</result>"
fi
And get the result for only one of the 2 version of Photoshop that is installed on my Mac. How can I get the result to show me the version of both Photoshops installed on my Mac?
Posted on 04-25-2014 02:05 PM
As I mentioned, you likely will need to use an array. Try something like this-
#!/bin/bash
PSInstalls=$( mdfind -onlyin /Applications/ 'kMDItemDisplayName == "Adobe Photoshop*" && kMDItemKind == "Application"' )
if [[ "$PSInstalls" == "" ]]; then
echo "<result>Photoshop not installed</result>"
else
while read app; do
appName=$(mdls -name kMDItemDisplayName "$app" | awk -F'"' '{print $2}')
appVersion=$(/usr/bin/defaults read "${app}/Contents/Info" CFBundleShortVersionString)
versList+=( "${appName}: ${appVersion}
" )
done < <( echo "$PSInstalls" )
echo -e "<result>${versList[@]}</result>"
fi
I can't test this because I'm not on a Mac with any version of Photoshop installed on it. But it should give you output along these lines-
<result>Adobe Photoshop CS4: 11.0.2
Adobe Photoshop CS6: 13.0.6</result>
Or-
<result>Photoshop not installed</result>
If it couldn't locate any installed version
If you'd rather not have the application path and name, just change this line-
versList+=( "${appName}: ${appVersion}
" )
To this-
versList+=( "${appVersion}
" )
And you'll see only the version number on separate lines
Posted on 02-28-2018 10:50 AM
So here is my issue.
Sophos has added a new version so I want a smart group created of Macs that don't have Sophos installed.
See below my script with both versions of Sophos for detection.
#!/bin/sh
#
############################################################################
#
# Extension Attribute checks to display Microsoft Word's Version with Release number.
#
# Uses CFBundleShortVersionString because this is the "release version number of the bundle"
# Ref: https://developer.apple.com/library/IOS/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
#
#
############################################################################
#
if [ -d /Applications/Sophos Endpoint.app ] ; then
RESULT=$( defaults read /Applications/Sophos Endpoint.app/Contents/Info.plist CFBundleShortVersionString )
echo "<result>$RESULT</result>"
elif [ -d /Applications/Sophos Anti-Virus.app ] ; then
RESULT=$( defaults read /Applications/Sophos Anti-Virus.app/Contents/Info.plist CFBundleShortVersionString )
echo "<result>$RESULT</result>"
else
echo "<result>Not Installed</result>"
fi
Posted on 03-02-2018 06:21 AM
@kericson i'm sorry i don't have an answer for you but wanted to thank you for resurrecting this old thread and making me giggle at the spelling error in the title.
happy friday :)