Chapter 13. Mixing AppleScript and Unix
Although Mac OS X is one of the nicest looking operating systems around, its Unix core is decidedly ugly. In Unix, you run programs by typing their names, not by double-clicking their icons. And not only that, if you misspell a Unix program’s name—or even mis-capitalize it—the program simply won’t run.
Still, Unix is the foundation of Mac OS X, and it’s got a few benefits to its name. For one, Unix is much older than Mac OS X, and it’s been refined by generations of programmers. As a result, it’s efficient, secure, and crash-resistant to its core.
As if that weren’t enough, Unix is a power user’s dream.
Often-used programs have quick, short names (ls,
cp, and mv, for example), and you can
redirect the results of one program into a completely separate program
with the pipe symbol, a simple vertical bar (|
). And since Unix was invented in the days
before graphical operating systems, it’s got tons
of timesaving keyboard shortcuts—like pressing the up arrow key to run a
previous Unix program.
Finally, there are some things you can only do with Unix. To tweak hidden Mac OS X settings, for example, you have to use a special Unix program called defaults. Or, if you want to admire how long your computer’s been running, the uptime program comes in handy. Either way, you’re getting information you can’t find anywhere else.
Note
The example scripts from this chapter can be found on the AppleScript Examples CD (see Sidebar 2.1 for instructions).
Terminal
Get AppleScript: The Missing Manual 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.