JAMF extensions attributes script

JamfAdmin2
New Contributor II

Hello I am new to scripting and i found this script online and i showed it to my boss he said "the script is good and it will work" he then asked me "how would that script look if it were to be in jamf extension" 

 

Here is the script i showed him i am assuming we are going to be using this script in jamf attributes extension but for it to be valid in jamf do i just need to add a results tag? how can this script be acceptable as a jamf extension? 

 

JamfAdmin2_0-1693342524045.png

 

9 REPLIES 9

jamf-42
Valued Contributor II

code is fine, but what exactly do you want the EA to return.. 

JamfAdmin2
New Contributor II

we just wanted to get a return of whatever version of slack a user currently has so we would run the script for example and tell us if the user currently has the silicon version of slack or the intel or the universal version of slack 

jamf-42
Valued Contributor II

thats cool, but whats the end game? you can just use JAMF apps and scope that for all Slack installs and that will take care of updates.. So you report back the binary version and then.. ? (unless your on prem.. then..) 

one of the things my boss asked me was "how can you update that script so it would work as a jamf extension" i never used jamf extensions before so that is why i asked i wanted to know more 

jamf-42
Valued Contributor II

ahh.. ok.. yea.. get whatever you need to parse into an variable..  $usefulldata

echo "<result>$usefulldata</result>"

will enter that into the EA, that you can then scope / report on.. 

if there is no data, I keep the variable empty..  

 

NOTE!! important.. EAs run as ROOT, and will execute what-ever you enter. and for EVERY DEVICE... 

So, every EA you build.. make as a policy / script .. assign, test.. test again. maybe.. again.. THEN add as an EA.. 😎

 

JamfAdmin2
New Contributor II

hey can you please do me a favor this script can you run it on your end please it is giving me syntax errors and i do not know why 

 

JamfAdmin2_6-1693346957672.png

 

JamfAdmin2
New Contributor II

JamfAdmin2_0-1693367526432.png

so with the script i am getting an error on line 7 and i do not know why and i do not know how to resolve the issue please help (:

mm2270
Legendary Contributor III

I see 2 possible things wrong with the script in your image. First, the first line in the case statement should be "x86_64 arm64", not just "x86_64" as you have it now. Otherwise, it will never detect any Universal versions of the application since the command outputs both the x86 and arm64 tags with universal apps.

Second thing, and this may be the reason for your error, is you should have a space between echo and "<result> for each line in your case statement. Spaces are important in shell scripts as they act as delineators between commands and other pieces of information. You can't smush them together like that.