Posted on 02-03-2022 11:20 AM
I am trying to check if a user is signed into Box on their machine but the script doesn't seem to be accessing the correct directory. Here is what I have
I believe the script isn't detecting the users account correctly like the $USER variable would if it was run locally. so my question is: Is there a way to have the script detect the current logged in user so it can access the users account directory?
Solved! Go to Solution.
Posted on 02-03-2022 11:53 AM
Figured this out by pulling the lastUserName property from the com.apple.loginwindow. So here is my current script for anyone in the future having this same problem.
02-03-2022 11:45 AM - edited 02-03-2022 11:46 AM
Jamf runs as root, so you would need to set a variable in your script to capture the logged in user.
Something like this should work:
USER=$( /usr/bin/stat -f %Su "/dev/console" )
Posted on 02-03-2022 02:40 PM
Thank you for the response! The $USER variable is automatically populated with the current user when the script is run locally on a machine. When I first wrote it I didn't think about the fact that JAMF wouldn't be able to detect the current user with the script being run remotely!
Posted on 02-03-2022 11:53 AM
Figured this out by pulling the lastUserName property from the com.apple.loginwindow. So here is my current script for anyone in the future having this same problem.