Create Script to run as current user and store on Users Desktop

dresslah
New Contributor III

I've researched these forums and tried to adjust a script to my needs but still getting an error when running it.

Main Goal: To get a savable list of 32-bit applications to the users desktop.

CURRENT SCRIPT:

!/bin/bash

sudo system_profiler SPApplicationsDataType | grep -B 6 -A 2 "(Intel): No" > /Users/$USER/Downloads/32BitApps.txt

I've tried setting $USER as a custom variable as well, same result. (syntax was username = $USER)

Any information would be appreciated. I'm somewhat new to shell scripting so if possible, so please take that into consideration.

1 REPLY 1

ShaunRMiller83
Contributor III

Try this... Also JAMF runs as root so the sudo shouldn't be needed.

!/bin/bash

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

system_profiler SPApplicationsDataType | grep -B 6 -A 2 "(Intel): No" > /Users/$loggedInUser/Desktop/32BitApps.txt