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.

User uploaded file


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

Posted on Aug 21, 2015 1:10 AM

Reply
1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to properly write defaults using AppleScript in Automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.