Skip to main content

Hi Everyone,

 

How can I get the list of apps installed with Brew? I could not pull this list with Jamf Pro via script. Because the brew list command should work in the corresponding profile. However, I guess Jamf Pro doesn't run it in the relevant profile. Is there a practical method? I used the following commands;

brew list --cask
brew list

shamelessly taken from Brew install script.. but this should run in user context.. NOT tested.. and could prob be written  better.. 

consoleuser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) HOMEBREW_PREFIX="/usr/local" su -l "$consoleuser" -c "${HOMEBREW_PREFIX}/bin/brew list -cask

shamelessly taken from Brew install script.. but this should run in user context.. NOT tested.. and could prob be written  better.. 

consoleuser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) HOMEBREW_PREFIX="/usr/local" su -l "$consoleuser" -c "${HOMEBREW_PREFIX}/bin/brew list -cask

 

 

Hi,

I got an error like this. Do you have an idea?

 

Script result: /Library/Application Support/JAMF/tmp/Brew List: line 3: unexpected EOF while looking for matching `"'
/Library/Application Support/JAMF/tmp/Brew List: line 4: syntax error: unexpected end of file


shamelessly taken from Brew install script.. but this should run in user context.. NOT tested.. and could prob be written  better.. 

consoleuser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' ) HOMEBREW_PREFIX="/usr/local" su -l "$consoleuser" -c "${HOMEBREW_PREFIX}/bin/brew list -cask

Hi,

 

I think the path information is much different than that. I have to write the correct one.


 

 

Hi,

I got an error like this. Do you have an idea?

 

Script result: /Library/Application Support/JAMF/tmp/Brew List: line 3: unexpected EOF while looking for matching `"'
/Library/Application Support/JAMF/tmp/Brew List: line 4: syntax error: unexpected end of file


my bad... copy paste.. let me down.. missing " on line 3

 

su -l "$consoleuser" -c "${HOMEBREW_PREFIX}/bin/brew list -cask"

 

which brew 

in terminal will give you install path.. to confirm / update

 


we use this EA to get that info as there is a path difference between ARM64 and X86. see if it helps. results modified so you may need to work on the spacing. Please test on a non-production device

#!/bin/sh # base result RESULT="Not Found" # Find machine type UNAME_MACHINE="$(uname -m)" cliapps=$(ls /usr/local/bin) if [[ "$UNAME_MACHINE" == "arm64" ]]; then # M1/arm64 machines if [[ -e /opt/homebrew/bin/brew ]]; then brewinstm1=$(ls /opt/homebrew/Caskroom) brewinstm1celler=$(ls /opt/homebrew/Cellar) fi else # Intel machines if [[ -e /usr/local/bin/brew ]]; then brewinsti1=$(ls /opt/homebrew/Caskroom) brewinsti1celler=$(ls /opt/homebrew/Cellar) fi fi echo "<result> CLI Installed Software: $cliapps: BREW M1 Installed software $brewinstm1 $brewinstm1celler BREW Installed Software Intel: $brewinsti1 $brewinsti1celler </result>"

 


You might find it helpful to explore some tips on the 7 Brew Drink Hacks to enhance your workflow with Brew. Sometimes, hidden tweaks and customizations can simplify managing installed apps or scripts across different profiles. Checking out these little-known methods could offer a fresh perspective on handling commands like brew list more effectively.