Osascript
Three command-line tools are
provided for accessing AppleScript from Unix. The first,
osalang
, lists the scripting components present
on your machine (see Section 4.2):
$ osalang -l
ascr appl cgxervdh AppleScript
scpt appl cgxervdh Generic Scripting System
If you have other OSA components installed, they will also appear. For example, if you use Script Debugger, you’ll see AppleScript Debugger and JavaScript. These do in fact appear on my machine, but to reduce confusion, they are not shown here.
The two four-letter codes identifying each component are used by OSA
programmers, but typically won’t arise in the
context of your AppleScript experience. Then comes a series of flags
describing the capabilities of this scripting component (see the
manpages for their meanings). Finally, we have the name of the
component. The “Generic Scripting
System” is the general front end to the OSA (what
Chapter 4 calls the GSC);
“AppleScript” is the AppleScript
component in particular. You can use either of these two terms as a
language specifier in calling the other two command-line tools, but
their effect will be identical, since the GSC will treat AppleScript
as the default component. In general, unless you are using other OSA
scripting components, you’ll have no need for
osalang
.
The osacompile
command takes as argument a text file,
or some text provided on the command line, and generates a
compiled script file or applet. There are options letting you determine the characteristics of ...
Get AppleScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.