Skip to main content

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?

 

 

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" )

 


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.

 

 


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" )

 


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!