Mac OS X Unleashed

Mac OS X Unleashed

By John Ray and William C. Ray

Command-Line Tools

AppleScript compilation and execution has been extended to the BSD shell through the use of the osacompile and osa s cript commands.

The osacompile utility accepts a text file containing AppleScript as input, and outputs a compiled script file using the syntax:

osacompile -o <output file> 
   <script file>

Although this is likely the form you'll use most, there are several additional command-line options that can fine-tune the compile process. Table 21.1 documents the additional options.

Table 21.1. Compile Options for os a compile

Option Purpose
-o Name the output file. The default output name is a.scpt.
-e Save the compiled file as execute-only.
-d Save the script in the data fork of the output file.
-r <type:id> Save the output script as the named resource type and ID.
-c <cre a tor> Set a creator code for the output script.
-t <file type> Set a file type code for the output script.

The osascript utility can be invoked to run as script by typing

osascript <script filename>

If a filename is not set specified on the command line, osascript will attempt to run AppleScript from standard input. This is a great way to test scripts, or run a quick AppleScript command without needing to start the Script Editor.

Share ThisShare This

Informit Network