How to properly write defaults using AppleScript in Automator
I am running this Applescript in Automator. I get prompted for my admin password as expected but am then seeing an error:
(Error)
Rep argument is not a dictionary
Defaults have not been changed.
My input is either 1 or 2 which I obtain by reading the current default for the domain specified.
(/bin/bash)
defaults read /Library/Preferences/com.apple.alf globalstate
(Applescript)
Generates the error after I login with admin account. Which implies that the problem is with the command. However the same command (in quotes) works when I enter it using the terminal.
on run {input, parameters}
if input = 1 then
do shell script "sudo defaults write /Library/Preferences/com.apple.alf 2" with administrator privileges
else
do shell script "sudo defaults write /Library/Preferences/com.apple.alf 1" with administrator privileges
end if
end run
MacBook Pro, OS X Yosemite (10.10.5), (OS X) Latest Beta