Create a Report for 32 Bit Apps

bassic
New Contributor III

I realise I am leaving this a little bit late with Catalina just around the corner, but what I really need is to be able to produce a spreadsheet of what 32 Bit Apps are installed on my Mac fleet, with details of which Mac they are on etc.

I am suprised there is not more chat on here about this- hopefully it's because there is an easy solution which I've overlooked!

I have rrouton's script to create a document on each Mac detailing the 32 bit Apps https://derflounder.wordpress.com/?s=32bit but I can't get this to work as an EA as others seem to be doing.

How is everyone else managing this? We do a lot of scientific computing here, and I suspect there are many 32 bit apps in use.

Thanks in advance!

1 ACCEPTED SOLUTION

bassic
New Contributor III

@amccarty You are the man! That worked perfectly- thanks so much for your help!

View solution in original post

50 REPLIES 50

Heavy_D
Contributor III
#!/bin/bash

# Detect all 32-bit apps installed in /Applications, /Library
# or /usr/local and output list to logfile stored in /var/log.


ThirtyTwoBit_app_logfile="/var/log/32bit_apps_installed.log"
ERROR=0

# this script must be run with root privileges
if [[ "$(/usr/bin/id -u)" -eq 0 ]]; then

    # Create log file if not present
    if [[ -f "$ThirtyTwoBit_app_logfile" ]]; then
       echo "$ThirtyTwoBit_app_logfile found. Proceeding..."
    else   
       echo "Creating $ThirtyTwoBit_app_logfile log. Proceeding..."
       touch "$ThirtyTwoBit_app_logfile"
    fi

    # Get a list of all installed applications
    ThirtyTwoBit_app_list=$(/usr/sbin/system_profiler SPApplicationsDataType)

    if [[ -n "$ThirtyTwoBit_app_list" ]]; then

        # Get all non-64 Bit applications from the initial list
        ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/grep -A3 "64-Bit (Intel): No")

        # Filter out all applications in /Applications, /Library and /usr/local
        ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/grep -E "Location:[^/]*/(Applications|Library|usr/local)/")

        # Remove everything except the path
        ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/sed -n 's/.*Location:[[:space:]]*(.*)/1/p')

        if [[ -n "$ThirtyTwoBit_app_list" ]]; then
            echo "$ThirtyTwoBit_app_list" > "$ThirtyTwoBit_app_logfile"
            echo "List of detected applications available in $ThirtyTwoBit_app_logfile"
        else
            echo "No 32-bit applications found in /Applications, /Library or /usr/local." > "$ThirtyTwoBit_app_logfile"
        fi
        # Get logged in user
        loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'

    #move the file to the desktop of logged in user
     mv "/var/log/32bit_apps_installed.log" /Users/$loggedInUser/Desktop

exit 0 ## Success
exit 1 ## Failure
fi
else log "ERROR! You must be root in order to run this script!" ERROR=1
fi
exit $ERROR

The following script did not work, created a file called Desktop in the users directory and when opened I see the echo'ed: No 32-bit applications found in /Applications, /Library or /usr/local.

@bassic can you post the script again using the correct forum post formatting?

bassic
New Contributor III

Hi @JarvisUno is this any better? It works perfectly for me...

#!/bin/bash

# Detect all 32-bit apps installed in /Applications, /Library
# or /usr/local and output list to logfile stored in /var/log.


ThirtyTwoBit_app_logfile="/var/log/32bit_apps_installed.log"
ERROR=0

# this script must be run with root privileges
if [[ "$(/usr/bin/id -u)" -eq 0 ]]; then

    # Create log file if not present
    if [[ -f "$ThirtyTwoBit_app_logfile" ]]; then
       echo "$ThirtyTwoBit_app_logfile found. Proceeding..."
    else   
       echo "Creating $ThirtyTwoBit_app_logfile log. Proceeding..."
       touch "$ThirtyTwoBit_app_logfile"
    fi

    # Get a list of all installed applications
    ThirtyTwoBit_app_list=$(/usr/sbin/system_profiler SPApplicationsDataType)

    if [[ -n "$ThirtyTwoBit_app_list" ]]; then

        # get all non-64 Bit applications from the initial list
        ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/grep -A3 "64-Bit (Intel): No")

        # filter out all applications in /Applications, /Library and /usr/local
        ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/grep -E "Location:[^/]*/(Applications|Library|usr/local)/")

        # remove everything except the path
        ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/sed -n 's/.*Location:[[:space:]]*(.*)/1/p')

        if [[ -n "$ThirtyTwoBit_app_list" ]]; then
            echo "$ThirtyTwoBit_app_list" > "$ThirtyTwoBit_app_logfile"
            echo "List of detected applications available in $ThirtyTwoBit_app_logfile"
        else
            echo "No 32-bit applications found in /Applications, /Library or /usr/local." > "$ThirtyTwoBit_app_logfile"
        fi


# get logged in user
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

# move the file to the desktop of logged in user
mv "/var/log/32bit_apps_installed.log" /Users/$loggedInUser/Desktop



exit 0      ## Success
exit 1      ## Failure

    fi

else
    log "ERROR! You must be root in order to run this script!"
    ERROR=1
fi

exit $ERROR

Heavy_D
Contributor III

@bassic Thank you very much I found my syntax error.
/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }' Is where I went wrong. I forgot to add the back quote to the variable. I only noticed it after I had made the initial post. And after proof reading the code noticed that, that the -l switch was not acting as an option.

When I added the back quote the issue resolved.

`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

jameson
Contributor II

@Hugonaut Just tried your script and deployed it with Jamf - but if fails

#!/bin/sh
Script result: /Library/Application Support/JAMF/tmp/32bit appls listed 31 jan:46:145: execution error: sh: /Users/root/Desktop/32bitapps.txt: No such file or directory (1)

I don´t have any root user and it cannot find this directory. Think the issue is that the script should be run in the logged in user mode?. Jamf run it as sudo so that is where the root account come from

tdilossi
Contributor

I ran this script and added it to Self Service. This way if a teacher plans to update they can see if they are running any apps which won't work in Catalina. They are in control of running it and if they have questions about the report they contact tech. This is working out well.

!/bin/bash

Detect all 32-bit apps installed in /Applications, /Library

or /usr/local and output list to logfile stored in /var/log.

ThirtyTwoBit_app_logfile="/var/log/32bit_apps_installed.log"
ERROR=0

this script must be run with root privileges

if [[ "$(/usr/bin/id -u)" -eq 0 ]]; then

# Create log file if not present if [[ -f "$ThirtyTwoBit_app_logfile" ]]; then echo "$ThirtyTwoBit_app_logfile found. Proceeding..." else echo "Creating $ThirtyTwoBit_app_logfile log. Proceeding..." touch "$ThirtyTwoBit_app_logfile" fi

# Get a list of all installed applications ThirtyTwoBit_app_list=$(/usr/sbin/system_profiler SPApplicationsDataType)

if [[ -n "$ThirtyTwoBit_app_list" ]]; then

# get all non-64 Bit applications from the initial list ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/grep -A3 "64-Bit (Intel): No")

# filter out all applications in /Applications, /Library and /usr/local ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/grep -E "Location:[^/]*/(Applications|Library|usr/local)/")

# remove everything except the path ThirtyTwoBit_app_list=$(echo "$ThirtyTwoBit_app_list" | /usr/bin/sed -n 's/.Location:[[:space:]](.*)/1/p')

if [[ -n "$ThirtyTwoBit_app_list" ]]; then echo "$ThirtyTwoBit_app_list" > "$ThirtyTwoBit_app_logfile" echo "List of detected applications available in $ThirtyTwoBit_app_logfile" else echo "No 32-bit applications found in /Applications, /Library or /usr/local." > "$ThirtyTwoBit_app_logfile" fi

get logged in user

loggedInUser=/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'

move the file to the desktop of logged in user

mv "/var/log/32bit_apps_installed.log" /Users/$loggedInUser/Desktop

exit 0 ## Success
exit 1 ## Failure

fi

else log "ERROR! You must be root in order to run this script!" ERROR=1
fi

exit $ERROR

jameson
Contributor II

So Cannot work as policy but only Self service ?

tdilossi
Contributor

No, it is a policy but I place it in Self service, because I don't need every teacher getting reports on their desktop because the questions would be incessant. The self-service policy gives the tech or the teacher the information they require, when they require it.

jameson
Contributor II

@bassic I tried your script and if I run it manual through command line as sudo it works. But when adding it as script, it just everytime write failed - without any kind of info in the log ?

Do you run it through Jamf ?

bassic
New Contributor III

Hi @jameson

Yes I run the script via a Self-Service policy. How are you deploying it?

tjhall
Contributor III

I've used Go64 (https://www.stclairsoft.com/Go64/index.html) which works well on an individual basis (I've already checked and updated most of our apps first which covers 95% of the app out users have installed).

jameson
Contributor II

I was tired of seing all bunch of nonsense listed in the EA, typical some adobe/microsoft that is rapported as 32bit, but will be no issue after upgrade. So to clean up, i´ve used sed to delete those application I do not want to see ( or users should think off)

#!/bin/bash
cat /var/log/32bit_apps_installed.log | sed -e '/Adobe/d' -e '/LWMacClient/d' -e '/Remote/d' -e '/TeamViewer/d' -e '/Microsoft/d' -e '/Google/d' > /var/log/32bit_apps_installed_edited.log