Embedding AppleScript inside a Bash -- getting Error

change

osascript <<EOF

to

osascript <<-EOF

The - lets you indent the terminating EOF.