This little example shows the syntax of how to run some AppleScript/osascript from a Unix shell script on a Mac OS X system:
#!/bin/sh osascript <<EOF tell application "Safari" close window 1 end tell EOF
Just put your AppleScript in between the
EOF parts, save it to a file, make the file executable, and this gives you a nice way to run a multiline AppleScript script from a shell script.
Here’s another example of what this looks like: