Teach Fetch New AppleScript Tricks
Want to use AppleScript to get more out of the Fetch FTP client? Try the Fetch 5 Example Scripts collection. You can use any script as provided, use them as a learning tool, or use them as a starting point for your own scripts.
Visit the Fetch download page
Series: Mac OS X and Unix
Chris Pepper examines the Unix underpinnings of Mac OS X - and their implications.
Article 1 of 2 in series
by Chris Pepper
With Mac OS X, Apple is building Unix into the Mac OS, and this has technical, social, and political ramifications for Mac users and the rest of the industryShow full article
With Mac OS X, Apple is building Unix into the Mac OS, and this has technical, social, and political ramifications for Mac users and the rest of the industry. To understand the implications of this change, let's take a look this week at the Unix family of operating systems and how they constitute a part of Mac OS X. In the next part of this article, I'll address how the fusion of these two operating systems will impact not only Mac and Unix users, but the computer industry as a whole.
Unix 101: The History of the Machine -- In the beginning (or as far back as we want to go), there was Unix, which was originally developed at AT&T's Bell Labs. In many ways, Unix grew up in symbiosis with the C programming language, which became an important facet of its underlying philosophy - that programming is good for you. (For more information, see some of the resources provided by Dennis Ritchie, one of the creators of C, as well as an interesting timeline of the history of Unix). In sharp contrast, the Macintosh was revolutionary because of Apple's concept that computer users could be insulated from the underlying workings of their computers, and not have to be programmers. Apple's vision of the Mac OS was as a system for managing a computing appliance, whereas Unix was published as a research project with an open invitation to tinkerers.
Over time, various companies and individuals contributed to Unix, each under their own licenses, some of which required payment for use. Several companies, most notably Sun Microsystems, licensed Unix to use as the basis of their own operating systems to run on their own computer hardware. There are now hundreds of derivatives of the original Bell Labs Unix. A crucial point in the development of Unix came when AT&T sued the University of California at Berkeley to halt distribution of Unix systems without paid licenses from AT&T, but the suit failed. After the settlement, Berkeley released the free and redistributable 4.4BSD-Lite (BSD stands for "Berkeley Software Distribution"), which contained no AT&T code and no licensing restrictions. The current BSD flavors of Unix - NetBSD, FreeBSD, OpenBSD, BSDI, and now Apple's Darwin - are all descendants of BSD-Lite.
During the 1980s, Richard Stallman formed the Free Software Foundation (FSF) to write a completely compatible Unix replacement, free of restrictive licensing requirements. In rejection of these licenses, the FSF created the GNU General Public License (GPL), which requires licensed software to be freely redistributable, and has a "viral" clause requiring that derivative works also be licensed under the GPL, and thus freely available and modifiable. The GNU (which stands for "GNU's Not Unix") project was highly successful in creating powerful tools, such as the ubiquitous gcc compiler and gzip compression program, now considered standard parts of Unix environments. The GNU operating system kernel, known as Hurd, is still under development.
Linus Torvalds began the Linux project with a similar goal: to develop a free Unix-compatible kernel for Intel PCs, without license encumbrances. To ensure that Linux would be free, it was also licensed under the GPL. An operating system kernel isn't useful by itself, so Linux distributions combine Linux kernels with other free GNU and non-GNU components to build complete operating systems. Thus the FSF's goal of a free Unix-like operating system was attained, though not quite as its founders expected.
Linux is generally portrayed as a better, faster, and more stable server alternative to Windows NT/2000. In contrast, BSD Unix rarely crops up in casual conversation, but its users consider it better and more stable than relative newcomer Linux. A number of high-profile Web sites, such as Yahoo and MCI, apparently share this conviction and rely on BSD-backed Web servers.
The Mac OS X Layer Cake -- Although Apple is introducing Unix to millions of Mac users through Mac OS X, you don't need to start memorizing Unix commands to use it (in fact, you'll have to work to see the Unix command line at all). However, it will be helpful to have a working knowledge of how Unix fits into the inner workings of your Mac.
Think of Mac OS X as a three-layer cake, borrowing its basic recipe from the NeXTstep operating system, leavened with components of Mac OS 9. The lowest level is derived from Carnegie Mellon University's Mach microkernel research project, which interacts with the hardware and helps different parts of the next level up communicate with one another, and the BSD kernel, which provides facilities such as networking, device drivers, and file systems - HFS+ and UFS (Universal or Unix File System) are included in Mac OS X. Within Darwin, the second level is a fairly standard Unix environment, including tools ranging from the ls program that lists files and the cp program that copies files, to the aforementioned gzip and the Apache Web server. These two layers are available now from Apple, packaged together as the free open source Darwin operating system.
Darwin is a fully capable Unix-like operating system on its own, but it's limited in comparison to the Mac OS. In particular, Darwin lacks graphics capabilities entirely - in a typical Unix system those would be provided by the X Window System, but Darwin can only display text on the connected monitor. Apple has released Darwin as open source, so people with recent Macs who want to run BSD-style Unix now have another free option (projects such as OpenBSD and NetBSD also support many Macintosh hardware configurations). Darwin has already drawn some attention in the computer industry, but it's mostly relevant for Mac users, since several mature BSD options for Intel-based PCs already exist. It remains to be seen whether people will actually use Darwin as an independent product, but it may find popularity on slightly older machines or in dedicated server environments.
Confusingly, Apple uses the name Darwin for several related projects which have different releases but the same source code: the self-contained Darwin operating system package and the bottom layer of Mac OS X. Direct access to Unix applications on a Mac OS X system is entirely optional, which makes the system much more palatable for Mac users who prefer to avoid Unix. But double-clicking the Terminal program included in Mac OS X Public Beta invokes a command line, giving full access to Unix functionality, just like logging into a machine running the free Darwin operating system.
The second and third levels of the Mac OS X layer cake, not included in the free Darwin package, are the proprietary code that makes it a Macintosh operating system with a graphical interface: the QuickDraw and Quartz graphic environments that programs use to draw to the screen and the whole set of Application Programming Interfaces (APIs) that enable Macintosh programs (as opposed to Unix programs) to run. The main APIs in Mac OS 9 are collectively called the Macintosh Toolbox. Mac OS X includes a much larger set of overlapping APIs, due to its hybrid Unix/NeXT/Apple heritage.
Classic applications rely on the venerable QuickDraw for display of text and graphics. Carbon applications can use Apple's new Quartz display engine, but QuickDraw remains available to them as well, and so they'll probably stick with QuickDraw as long as developers want to provide a single application file that can run under both Mac OS 9 and Mac OS X. Cocoa applications rely entirely on Quartz, which is based on Adobe's Portable Document Format (PDF), and provides improved capabilities for print and layout. In addition, Mac OS X also provides OpenGL and QuickTime, which may help availability and performance of games and scientific computing software for Macs.
Macintosh programs that can run under Mac OS X come in three main flavors: Carbon, Classic (existing Mac OS 9 programs), and Cocoa. New and updated programs which use Carbon are full-fledged Mac OS X applications and take advantage of Mac OS X's protected memory and preemptive multitasking. Current programs run under Mac OS 9 within the Classic environment, providing compatibility with existing software. And Cocoa programs rely on a set of APIs originally derived from NeXTstep, so Mac OS X can run NeXTstep-derived programs.
The frosting on this layer cake is a new graphical design for Mac OS X, called Aqua. All Carbon and Cocoa applications in Mac OS X use Aqua, which specifies larger text and buttons, heavy usage of anti-aliased text and transparency, and a new set of design guidelines for windows, menus, and other interface elements. As a result, Mac OS X applications are prettier and livelier, with correspondingly increased demands on processor power and screen size. Specifically, Mac OS X effectively requires a minimum screen resolution of 800 by 600 pixels, while Mac OS 9 was usable at 640 by 480 pixels. (Also see "A Quick Dip into Aqua, the Mac OS X Interface" in TidBITS-513.)
Okay, let's see if we can put it all together - this diagram may look more like a game of Hack than a layer cake, but it should give you an overview of where everything fits. Remember there's no graphical environment under BSD Unix in Darwin.
| (Platinum) | (Aqua) | | (Text) | +-------------+----------+---------+ +------------+ 3 | Classic | Carbon | Cocoa | | BSD Unix |\ +-------------+----+-----+---------+ +-----++-----+ \ 2 | QuickDraw | Quartz | || (Darwin) +------------------+---------------+---------++-----+ / 1 | Mach+BSD kernel |/ +---------------------------------------------------+
To continue our analogy, the Mac OS X Public Beta available now includes candles on the cake - user applications (both included with Mac OS X and installed by users), which use either the Platinum (Classic) or Aqua appearance, depending on the APIs to which they're written. Bundled applications include the Finder/Desktop, Internet Explorer, Mail, Sherlock, System Preferences, an MP3/CD player, and others. The whole installation provides approximately the same feature set as Mac OS 9, but as you'd expect in a beta, some of the new components are more primitive than the mature ones from Mac OS 9. The best example of this is the new Dock, which replaces Mac OS 9's Apple and Application menus and desktop, but doesn't offer the same level of flexibility as the older tools in Mac OS 9.
As a Macintosh system, the most obvious changes in Mac OS X are the visual interface - Aqua - and the file system layout. The underlying system is already more stable, but this is a less obvious change. Classic Mac developers are beginning to move their software to Carbon, and as they do so they will begin to take advantage of Carbon's new capabilities and advantages. For those interested in exploring further, there's a wealth of new territory. NeXT developers are quickly moving over to Mac OS X, and adapting their applications for Cocoa. Darwin's Unix environment provides a whole new range of capabilities, particularly in the areas of networking and programming. This is foreign ground for many Mac users, but the potential is considerable.
In the next installment of this article, I'll talk about how the computer industry stands to be affected by Mac OS X's merger of an underlying Unix structure with the qualities that make a Macintosh.
[Chris Pepper is a systems administrator in New York, and he's just delighted that his "personal" Mac workstations are now running Unix like the servers he coddles for a living. Check out his Mac OS X Software and Information site for more on Apple's new operating system.]
Article 2 of 2 in series
by Chris Pepper
With Mac OS X, Apple is bringing Unix to a large, new audience. In part one of this article, I offered a brief history of Unix and mapped out how Unix will provide the basis of Mac OS XShow full article
With Mac OS X, Apple is bringing Unix to a large, new audience. In part one of this article, I offered a brief history of Unix and mapped out how Unix will provide the basis of Mac OS X. The Macintosh user community is comprised of well over 25 million people, so as Apple paves a new path - even if most don't follow it immediately (or ever) - the implications for the industry are significant. Apple's last major change of direction, the iMac, introduced translucent colors, a strikingly original case design, USB, the removal of floppy disks and serial ports, and Internet access as a major feature. The iMac had a profound impact on the whole industry - even PC and PDA users without iMacs were affected by the iMac's endorsement of colors and USB. To understand Apple's latest decisions behind Mac OS X and its impact, it's necessary to examine Mac OS X, Unix, and the industry as a whole.
Competition Makes Strange Bedfellows -- In this industry, the dominant player is obvious: Microsoft. In fact, Microsoft is so much larger and more entrenched than any other company, including Apple, that they're almost a feature of the landscape. All Apple's plans for years have been made around the realities of playing with, against, and off of Windows PCs. As it turns out, this is just as true for Linux and BSD Unix users - perhaps even more so, because the PCs that Linux and BSD generally run on can (and often do) also run Windows. This raises an interesting question: are Apple and users of Unix-based systems natural allies, trying to carve different niches from the Windows market? It would seem that by basing Mac OS X on BSD Unix, at least Apple is endorsing this view.
Despite their fundamental differences, the Mac OS and Unix have a number of interesting similarities. Both platforms are shadowed by Microsoft's dominance but boast vigorous support within their own communities. The Mac OS and Unix have to "fit in and stand out," and success is often determined by how well they integrate with Windows. Windows can't (without the addition of a utility like Mediafour's MacDrive 2000) read Mac or Unix file formats or disk formats, but Macs and many Unix systems can both read Windows (FAT) floppies and hard disks. In contrast, Windows has so much market share that various "private" Microsoft technologies, such as the Word .doc file format and the Win32 APIs, have become de facto standards. In turn, Macs and Unix machines support these Microsoft-originated technologies to varying degrees, with Mac OS features like File Exchange and third-party products like Thursby Software's DAVE, which enables Macs to do Windows file sharing. The Mac OS and Unix must offer major advantages to be considered in spite of compatibility issues and have to take a much more open attitude towards compatibility and interoperability.
Because the capability to run other operating systems, particularly Windows, is so valuable, emulators are popular on Macs and Unix machines. Full emulators like Virtual PC provide all the capabilities of a foreign computer system, allowing other operating systems to run within the emulator. In this way, Virtual PC can run Windows, Linux, and other operating systems intended for Intel-based PCs. An alternative is to replicate only the operating system's functionality with a replacement compatibility layer. This approach is popular on PCs, where the processors are the same, so emulating just Windows, instead of a whole PC, provides a workable system. This is also how the Classic environment in Mac OS X works, and how the free Mac-on-Linux project runs Mac OS 8.6 and later under Linux on PowerPC-based computers.
Unix is often seen as the operating system for serious computer experts. At the other end of the continuum, Macs are "computers for the rest of us". Together, Unix and the Mac OS bracket Microsoft's huge lump in the bell curve of platform usage. Macs and Unix often differentiate themselves from Windows on the same issues, but take opposite tacks in doing so. Examples of such divergence include the Mac's ease of use, tight hardware-software integration, and - until now - unified control over hardware and operating system development; in contrast, Unix supporters tout advantages such as flexibility, control, broad hardware support, and reliance on open source projects.
Real World Differences -- Despite these similarities, we shouldn't lose sight of the fact that the Mac OS and Unix are in many ways utterly different. Unix has a long and distinguished history as a collaborative research project and programming environment. Over the years, it has matured into a robust and efficient networking platform, while remaining excellent as a development environment. In obvious contrast, Apple considers Macs to be powerful appliances, or sometimes technological agents, but doesn't expect users to develop software or explore the system. As open source advocates love to point out, Unix development is a worldwide and long-running effort, so Unix is very mature in their terms - stable and fast. On the other hand, Mac OS 9's maturity is visible in its consistency among applications and its well-honed interface. This is part of why the recent QuickTime and Sherlock interfaces (and many of the changes in Mac OS X's interface) cause such dismay among Mac users - they throw years of interface improvement and familiarity out the window, abandoning a long history of deliberate and incremental improvement in favor of novelty and glitz.
Over its long history, Unix has developed an extensive stable of software, especially in the networking, programming, and security arenas. "Productivity" applications, however, are much less common on Unix than on Macs and Windows, where they're staples - used by millions of people each day. A quick glance at the Freshmeat Linux/Unix software release site shows a wealth of programming tools, servers, and hacks, but little in the word processing, publishing, and spreadsheet areas. This makes a lot of sense when you remember that Linux machines can also run Windows, so many Linux users may also be using Microsoft Office under Windows on the same machines they use for Linux, or on secondary machines or client workstations, reserving the Unix machines as servers or programming environments. This is something of a self-fulfilling prophecy - because Unix is so impoverished in business software, Unix users generally require additional systems for such work, and because they have alternatives, there's less demand for these applications on Unix. As a result, Unix remains an excellent server platform, with notably different usage patterns than Mac OS and Windows.
Grand Unixification -- With Mac OS X, Apple has done a fair job of reconciling these two worlds in a brand-new combination, and an excellent job of isolating them enough that users can remain within a single familiar environment if desired. There are rough edges (particularly the three different views of the file structure: Mac OS 9/Classic, the slightly different Mac OS X layout, and the NeXT/Unix structure), but when Mac OS X is running, it's easy to ignore the Unix aspects, and remain in a familiar Mac environment with bigger icons, different buttons, and a much more limited Desktop.
This is apparently Apple's expectation for most users - that they will completely ignore the underlying Darwin layer, while still benefiting from its stability and performance. Alternatively, if you use the included Terminal program to log into the Darwin environment, you encounter a fairly normal Unix installation (except that, again, files are in strange places - a leftover from Mac OS X's NeXT heritage).
In additional to trying to create a unified system, Apple is also trying to move the proprietary work NeXT did on NeXTstep back into the BSD/Unix mainstream. Apple has repeatedly stated that their goal is to use as much generic BSD code as possible, thus saving time and money for maintenance of proprietary Apple software. As part of this process, Apple has released Darwin under an open source license, which means the program code is available for non-Apple developers to see, critique, and modify. In licensing terms, Mac OS X consists of two parts. The Darwin code is public and free, and the rest (the graphical and Mac-specific parts) is proprietary. This is a reasonable division, as Apple's focus has never been robust core operating system functionality, but rather the user interface. If taking Darwin open source proves successful [and comments from Darwin developers at MacHack 2000 seemed to indicate it already has been -Adam], Apple will garner significant development support from other developers, helping to improve the Darwin foundation for Mac OS X, and freeing more Apple developers to focus on Apple's strengths.
This split between the open source foundation and proprietary upper layers gives Apple what they've been desperately seeking for years: a version of the Mac OS that includes all the buzzwords important for a good, fast, stable operating system. BSD is stable and features preemptive multitasking, and provides excellent virtual memory and crash protection. Apple's hope is that existing Macintosh users will appreciate these features, and that they'll also attract a new class of users: serious network users and server administrators. With Mac OS X, Apple is taking a stride towards making the Mac an excellent server platform - even for serving Windows users. Plus, with high-bandwidth Internet connections becoming available and popular, Apple might just be on the cusp of empowering another leap in self-publishing. Mac OS X now includes Apache, gcc, cron, ssh, mainstream Perl, and a whole slate of Unix-based staples which were simply unavailable for Macs before, or required interface hacks and significant porting effort to run on the Mac. Mac OS X with Apache is already a much better personal server platform than Windows 98 or Microsoft's new Windows Me.
What Does Unix Mean to Me? Historically, Macs have had limited support for the latest Internet protocols and security tools. Although Mac OS 9 has an excellent track record for security, and there are several excellent mail, Web, FTP, and news clients, Macs have been too small a population to garner the same level of support as Windows from many vendors. This results in fewer options for virtual private networks (VPNs), PPP over Ethernet (PPoE, required for many cable and DSL ISPs), and similar networking tools and utilities. Mac OS X brings Unix-based tools to fill these needs. In many areas, this move should help eliminate the problems of being a niche player which have plagued the Mac OS for years.
The union of the Mac OS with Unix also has interesting sociopolitical implications for Mac users in the larger industry. With the Apple and Apple II, Apple made computers much more affordable and accessible to individual users. With the original Power Macintoshes, Apple became the only high-volume RISC (Reduced Instruction Set Computing, a design model that enabled PowerPCs to be so much faster than the previous Motorola 68000 series) computer vendor, bringing a major speed improvement to its users. If Mac OS X is even somewhat successful, within a year it will more than double the number of computer systems running BSD-based operating systems, even though Mac OS X users won't see their computers as Unix systems.
It will be interesting to see if and how Apple uses this new leverage into the Unix world, and if Apple takes advantage of the power of Unix directly, or instead restricts its focus to Aqua-based graphical applications. Thanks to hybrid applications, Apple may not have to make the choice. The FizzillaMach Web browser, for instance, uses a Carbon front end with an Aqua interface, but the standard Unix-based Mozilla back end for high-performance threaded networking. In the future, I hope to see Mac developers using the powerful Unix utilities included in Darwin from their Mac applications, perhaps through AppleScript scripts that pass text from Carbon to command-line programs like grep, sed, and wget, (which find matches, find and replace text, and get Web pages and sites, respectively) returning results to the Mac applications.
Apple is bringing us into the Unix world, like it or not. It is important to remember that Mac OS X's Darwin foundation offers major advantages for Mac users in two very different areas. First, it provides much better reliability and power than Mac OS 9, almost invisibly. Even users who completely ignore Darwin will silently benefit from its robustness and performance. Second, Darwin provides access to the tools and operating system facilities that make Unix so powerful, like shell scripting and networking tools.
Each user of Mac OS X will have to make their own decisions on whether and how much to venture beyond familiar Macintosh territory into the domain of Unix, but the capability will always be there. For me, at least, it's been the beginning of an exciting journey.
[Chris Pepper is a Linux and Solaris system administrator in New York, and he's just delighted that his Mac workstations are now running Unix like the servers he coddles for a living. If you want Chris to coddle your servers, check out his resume and contact him directly. His Mac OS X Software and Information site has links to useful information and a few Unix ports for Apple's new operating systems.]