Posted on 11-08-2021 12:04 PM
I'm working on a script that can run to secure screen screen saver corners. The through is I pull the usernames of non system accounts and put the commands below through a forloop.
Below is my for loop with variable. I added an echo in my troubleshooting. It looks like my for loop isn’t breaking apart each users in the variable’s array.
Anyone run into this or know what I am missing here?
=====================
adminuser@test-mac ~ % userList=$(dscl /Local/Default -list /Users uid | awk '$2 >= 100 && $0 !~ /^_/ { print $1 }')
for u in $userList
do
Echo $user
sudo -u $u defaults write com.apple.dock wvous-tl-corner -int 0
sudo -u $u defaults write com.apple.dock wvous-bl-corner -int 0
sudo -u $u defaults write com.apple.dock wvous-tr-corner -int 0
sudo -u $u defaults write com.apple.dock wvous-br-corner -int 0
done
john.doe
adminuser
sudo: unknown user: john.doe
adminuser
sudo: error initializing audit plugin sudoers_audit
sudo: unknown user: john.doe
adminuser
sudo: error initializing audit plugin sudoers_audit
sudo: unknown user: john.doe
adminuser
sudo: error initializing audit plugin sudoers_audit
sudo: unknown user: john.doe
adminuser
sudo: error initializing audit plugin sudoers_audit
adminuser@test-mac ~ %
Solved! Go to Solution.
11-08-2021 12:21 PM - edited 11-08-2021 12:21 PM
#!/bin/zsh
for dscl_user in $(dscl /Local/Default -list /Users uid | awk '$2 >= 100 && $0 !~ /^_/ { print $1 }')
do
echo ${dscl_user}
done
You have to run the script also with sudo otherwise it will not work!
11-08-2021 12:21 PM - edited 11-08-2021 12:21 PM
#!/bin/zsh
for dscl_user in $(dscl /Local/Default -list /Users uid | awk '$2 >= 100 && $0 !~ /^_/ { print $1 }')
do
echo ${dscl_user}
done
You have to run the script also with sudo otherwise it will not work!
Posted on 11-08-2021 12:35 PM
Thanks! This did the trick.