Skip to main content

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.

 

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.


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.


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


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


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.


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


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. 


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. 


Thanks for the info r0blee, this is very helpful.