Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Indeed you are correct. I missed the first end tell of the script. Commented Sep 29, 2013 at 1:29
  • Any reason you don't need the -e on the HEREDOC example? Commented Apr 23, 2018 at 14:55
  • @iconoclast Per the man page on osascript it is one line of script. -e statement Enter one line of a script. If -e is given, osascript will not look for a filename in the argument list. Multiple -e options may be given to build up a multi-line script. Because most scripts use characters that are special to many shell programs (for example, AppleScript uses single and double quote marks, ``('', ``)'', and ``*''), the statement will have to be correctly quoted and escaped to get it past the shell intact. Commented Mar 12, 2019 at 6:16
  • Sorry @uchuugaka, but I'm failing to understand how your response answers my question. In -e statement Enter one line of a script there is an -e present. But apart from that, is a HEREDOC treated as though it were a single line? Commented Mar 12, 2019 at 16:24
  • @iconoclast - one simple rule for this. If you can | pipe into a command, then you can HEREDOC to it, as both methods are communicating with the command via stdin. This also means you can use the command as a shebang, e.g. /usr/bin/osascript. (Which is also using stdin to send input to the process). Try echo "set Volume 2" | osascript for a quick test. Commented Jul 9, 2022 at 2:44