I'm running into problems with a shell script that utilizes a small portion of Applescript. When I compile it with Applescript editor it works. It does not though within a shell script.
44:49: syntax error: Expected end of line but found command name. (-2741) 23:28: syntax error: Expected end of line but found “after”. (-2741)
Here is the shell code:
osascript -e 'tell application "System Events" -e 'activate'
osascript -e 'tell process "Application 10.5" -e 'set frontmost to true' -e 'end tell'
osascript -e 'delay 1' -e 'keystroke return' -e 'delay 1' -e 'keystroke return'
end tell
Applescript (that works):
tell application "System Events"
activate
tell process "Application 10.5"
set frontmost to true
end tell
delay 1
keystroke return
delay 1
keystroke return
end tell
[updated] / [solved]
This took care of any kind of problems I was having trying to modify the applescript to work within a shell script:
## shell script code
echo "shell script code"
echo "shell script code"
## applescript code
osascript <<EOF
tell application "Scriptable Text Editor"
make new window
activate
set contents of window 1 to "Hello World!" & return
end tell
EOF
## resume shell script...
It's very cool that you're able to put pure applescript directly into a shell script. ;-)