Skip to main content
Solved

Run command at user level via simple script


Forum|alt.badge.img+6

Hello! I am very inexperienced with scripting, so tell me if i'm in the wrong place.

I want to have a simple script execute the following (at a user level):

defaults write com.apple.loginwindow TALLogoutSavesState -bool false

I have a few scripts (for mounting network shares) that I run using Outset when the user logs in. I'd like to do the same with this one. Any guide on how to call this command as the user?

Best answer by jan_rosenfeld

so I just ran this:

#!/bin/sh
user=`ls -la /dev/console | cut -d " " -f 4`
sudo -u $user defaults write com.apple.loginwindow TALLogoutSavesState -bool false

using outset, which runs the script as user upon login-once. and it worked! I think I'm good.

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+6
  • Author
  • Contributor
  • 23 replies
  • Answer
  • February 17, 2020

so I just ran this:

#!/bin/sh
user=`ls -la /dev/console | cut -d " " -f 4`
sudo -u $user defaults write com.apple.loginwindow TALLogoutSavesState -bool false

using outset, which runs the script as user upon login-once. and it worked! I think I'm good.


syed_hyder
Forum|alt.badge.img+2
  • New Contributor
  • 8 replies
  • February 6, 2023
jan_rosenfeld wrote:

so I just ran this:

#!/bin/sh
user=`ls -la /dev/console | cut -d " " -f 4`
sudo -u $user defaults write com.apple.loginwindow TALLogoutSavesState -bool false

using outset, which runs the script as user upon login-once. and it worked! I think I'm good.


I have just used your script on one of the policies and it helped me. Thanks @jan_rosenfeld


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings