Use script to disable "smart quotes" on all mac

SuperGrover
New Contributor II

Im trying to create a self-service policy with a script that will disable the "smart quotes" system setting but am running into issues getting this to work. 

 

 

defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

 

 

Above command seems to work fine when using it on my local device but when trying to use this command in a jamf policy, no luck. any ideas on how I can get this to work? Thanks in advance.

 

1 ACCEPTED SOLUTION

r0blee
New Contributor III

So as @AJPinto has pointed out the Jamf binary will execute everything as root but Jamf also knows who the current user is and stores that in the variable $2 at runtime so you could try something like the following to run it as the current user:

su $2 -c "defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false"

Alternatively you could get the current user yourself via another command and then use those 2 commands in the files and processes payload of a policy:

 

currentUser=$(stat -f "%Su" /dev/console); su $currentUser -c "defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false"

 Hope that helps. 

View solution in original post

5 REPLIES 5

AJPinto
Honored Contributor II

How are you trying to deploy it? If it works when you run it manually, but not when you run it with JAMF I am going to wager its something that needs to be done in the user space and not root space. Keep in mind everything JAMF does is done as root.

SuperGrover
New Contributor II

Thanks for the reply, Iv been deploying it as a "File and process > Execute Command". Ill give it a try using the user space. 

AJPinto
Honored Contributor II

Yep, that runs the command as root. If it is something that needs to be done in the user space, you are setting the value for the root user.

r0blee
New Contributor III

So as @AJPinto has pointed out the Jamf binary will execute everything as root but Jamf also knows who the current user is and stores that in the variable $2 at runtime so you could try something like the following to run it as the current user:

su $2 -c "defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false"

Alternatively you could get the current user yourself via another command and then use those 2 commands in the files and processes payload of a policy:

 

currentUser=$(stat -f "%Su" /dev/console); su $currentUser -c "defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false"

 Hope that helps. 

SuperGrover
New Contributor II

Thanks for the info r0blee, this is very helpful.