Apps Installed with Brew

husnudagidir
Contributor

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

2 ACCEPTED SOLUTIONS

jamf-42
Valued Contributor II

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

 

View solution in original post

efil4xiN
Contributor II

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>"

 

View solution in original post

5 REPLIES 5

jamf-42
Valued Contributor II

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

jamf-42
Valued Contributor II

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

 

Hi,

 

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

efil4xiN
Contributor II

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>"