An apple script that writes to the plist

I am super new when it comes to creating apple scripts.

I’m trying to create a few apple scripts that writes to the Info plist.
My main purpose for this is to simply automate the writing to the Server Address string assignment with out having to open up the terminal and type out the following:

(user)$ defaults write /Applications/(NameofApp)\ ServerAddress “

Since we are constantly having to quickly switch from one ServerAddress to another while doing some group coordinated testing; I figured the quickest way to make sure that we are all on the same page before we execute our testing is to simply click on the apple scripts and tadaa! We are all pointing to the server address of choice without the hassle of typing stuff out. Therefore eliminating human error and setbacks.
This is the Key and String I’m writing to in the app’s Info.plist


It would be great to also get an output for “defaults read” as well so we can confirm that the script indeed succeeded in changing the plist.

Anyone’s help with this would be greatly appreciated!:slight_smile:

To do this from AppleScript you use ‘do shell script’. Just give it the (almost) same thing as you posted.
Use quoted form of path - you put a backslash there:

do shell script "defaults write '/Applications/(NameofApp)' ServerAddress \"\""

Works with ‘defaults read’ same way:

set theServer to do shell script "defaults read '/Applications/(NameofApp)' ServerAddress"

display dialog "Server is now " & theServer