Posted on 01-09-2024 08:12 AM
Feel like I have to be missing something obvious here... but I can't seem to get this to behave. Trying to make an extension attribute that checks if homebrew is installed, and outputs the result of "which brew" if so.... pretty basic. This works perfectly from terminal both as my standard user and as root... but when jamf runs it... all that's returned to the extension attribute is "Installed: " with no file path listed.
From terminal, i get what seems to be a proper output jamf should be happy with:
sh-3.2# ./test2.sh
<result>Installed: /opt/homebrew/bin/brew</result>
Extension Attribute Code:
#!/bin/bash
if [[ $(which brew) != "brew not found" ]]; then
brewstatus="Installed: $(which brew)"
else
brewstatus="Not installed"
fi
echo "<result>$brewstatus</result>"
exit 0
Solved! Go to Solution.
Posted on 01-09-2024 08:58 AM
annnd eventually found an answer here - guessing its something to do with my path and profile, if i run this as the current user things seem to behave... https://community.jamf.com/t5/jamf-pro/homebrew-detection/td-p/275201
Posted on 01-09-2024 08:36 AM
Ok, so realized my if logic was wrong if brew *isn't* installed - as which is blank in that case as root, but that still doesn't solve the original problem of the path not being brought into the extension attribute... updating my code snippet regardless:
#!/bin/bash
if [ -z $(which brew) !]; then
brewstatus="Not Installed"
else
brewstatus="Installed: $(which brew)"
fi
echo "<result>$brewstatus</result>"
exit 0
Posted on 01-09-2024 08:48 AM
Condensed down to a super basic test - this comes back blank: seems like it's just not bringing in the output of that command... or perhaps which brew is returning blank when jamf runs it? I get output when i run it as root...
echo "<result>$(which brew)</result>"
exit 0
Posted on 01-09-2024 08:58 AM
annnd eventually found an answer here - guessing its something to do with my path and profile, if i run this as the current user things seem to behave... https://community.jamf.com/t5/jamf-pro/homebrew-detection/td-p/275201