Skip to content

currentUser returning multiple users #22

@marckerr

Description

@marckerr

We have noticed the script s having issues on newer Macs and trying to run the process on multiple users. The way the currentUser is found should be changed to what Scripting OS X has outlined here https://scriptingosx.com/2019/09/get-current-user-in-shell-scripts-on-macos/

Make the following change in the script

#currentUser=$(who | awk '/console/{print $1}')
currentUser=$( scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }' )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions