views:

530

answers:

1

Hi Everyone:

I am attempting to run some AppleScript in the terminal, just to learn how to do it, and I am running into some trouble with the & sign. Even when the & is replaced with the "&", it still returns the same error.. I have narrowed it down to the problem with the & sign, and am wondering if anyone has any advice about it. I am getting the following error:

syntax error: Expected expression but found unknown token.

My code that I type into the terminal:

osascript -e 'tell application "Finder"' -e 'set location to (path to home folder as string) & \"testing.plist\"' -e 'if (exists file location) then' -e 'say location' -e 'end if' -e 'end tell'

Thanks for any help.

+1  A: 

You don't need the backslashes to escape the double quotes for "testing.plist", removing those will fix that error.

Additionally, the word "location" is used by the Finder dictionary, so you'll want to use some other term for that variable, such as "myLocation" instead.

Brian Webster
Hi Brian: Thanks for your advice. It fixed my problem.
PF1