---
title: WWDC2003 Session 613
framework: wwdc
role: article
path: wwdc/wwdc2003-613
---

# WWDC2003 Session 613

## Transcript

Kind: captions Language: en [Applause] good afternoon and welcome to session 613 migrating UNIX his admin tools to Makka was 10 what I think we have a really nice panel of experts who are going to tell you about various experiences moving their tools over to Matco is 10 that we very helpful we already know that mac OS 10 is the best development environment it's also a fantastic sued admin environment and using all these Apple technologies wirelessly connected being able to manage giant racks of servers in your data center is a blast a lot of fun today we have Kevin Boyd who is going to from the University of Michigan who will explain what the environment is like for University of Michigan and their experience of bringing over their tools for a very diverse group of Sue's admins and managers next up what car Malik of our developer technical support is going to explain some of the gotchas importing over some of your scripts and tools and applications you've written and and finally Mike Bombeck of our field consulting engineers well known for his work on the side and his fantastic tool that we all use is going to describe how to build a great GUI interface on top of those command line tools so first off I'd like to introduce Kevin void University of Michigan and on the steering committee of Mac os10 labs org Kevin thanks a lot skip hi today I'm going to talk to you guys about how we as developers can work with administrators from all different types of computing platforms to create applications that administrators will want to use in Mac OS 10 Who am I good question I'm a administrator at the University of Michigan and also I am one of the steering committee members for the UEF lab group that also runs the site that's known as Mac os10 labs org and my responsibilities primarily have been in relationship to this project development of lab management tools that ease the transition from some other computing platform to Mac OS 10 at the University of Michigan this is a very complex environment known as a distributed computing environment which has a lot of potential challenges for administrators and developers because of the distribute computing environment there's the ability given to our administrators to pick any type of computing platforms and any type of operating systems that they may want to run inside of their own environments and we'll get into more detail on that in a moment it's a great graphic here it really looks really good if you can see the whole picture it has a whole bunch of computers and arrows and things plenty of each other I don't think it made the final cut okay so if we go back in time we can look at how Mac OS 9 was managed at the University of Michigan and we start to see why administrators like the Macintosh experience when it came to managing machines in their environment it was easy to manage because of the operating system it had an easy-to-use interface it was intuitive and it didn't take a lot of learning for you to understand how to use a Macintosh computer and it was accepted for users to go out administrators to go out onto the net contact third parties do whatever it takes to make the machine as secure and consistent computer platform for you inside of a lab management environment at the same time on our campus we had many other platforms that were unix-based and these people had skills that allow them to manage their machines but the learning curve was incredibly steep and the ability to manage the machines was incredibly difficult and these two groups really could not have skills that transferred from one group to the other we at Michigan saw Mac os10 as an opportunity to take all of our experiences creating utilities and tools for managing machines in OS 9 and in UNIX and combining them in such a way that we could have truly the holy grail of computing and lab administration which would be ease of use ease of migration ease of integration and also to be able to say I have skills that I've gained from learning how to use this machine that can be transferred from other computing platforms I have a skill set that applies not only to these Macintosh computers that can also be used in other environments as well so we've leveraged our experiences in these environments we've developed applications that you've heard about throughout the week or at our site or you know we can talk about them here too that have really taken advantage of all this experience the challenge has been how are we going to continue to make tools that administrators want to use so let's take a look at one of the places where I had a chance to spend some time at the University of Michigan developing tools for mac OS 9 users and from there we can decide whether or not these are why was it successful what did we do that was so successful what happened here that we can tell developers go out and do this and it will make mac OS 9 users want to use Mac OS 10 as we already stated the University of Michigan is a distributed computing environment and with the freedoms that we allow administrators to have it presents enterprise computing and its most complex level because there's freedoms in terms of hardware software data people and procedures that we let the administrators have in order to create their computing environment the same time we want to have the users that use these computers computing environments to have a consistent computing experience from one lab to another so let's focus now our discussion a little bit and talk about the School of Art and Design at the University of Michigan I've spent a lot of time with the OS 9 administrators there and that's really where I became involved in OS 10 so here we have the traditional view of Mac OS 9 and why people like using Mac OS 9 and we have the traditional view of UNIX and how people use unix and what was good about each platform utilities like a simulator were nice because well to put it simply it was easy use it didn't require you to know a lot about the underpinnings of the machine in order to manage a large set of computers in your computing environment however tools like this and almost all the tools that were available for Mac OS 9 didn't scale they weren't readily usable in a wide range of machines across an entire computing enterprise while on the other hand the UNIX operating systems gave you all of the network integration technologies that you needed for enterprise computing but learning how to implement them learning how to use them correctly and learning how to make them fit into your environment required incredibly steep learning curve so we have the problem laid out how do we create tools that administrators will use well I think the first thing we need to do is identify the expectations and the benefits that began can be gained from looking at our core audience who are we trying to help who are we trying to create these applications for I think we can be divided into three groups you have your diehard Mac OS 9 administrators these are people who even today are still not migrated still have not decided to take a look at mac OS 10 you have your hardcore unix administrators these are people who they may say things like mac OS 10 is in a real OS it's not a real UNIX well we all know it is and it's up to us as developers to prove to them that it is and you have your Mac os10 administrators these are people who realize the power of UNIX because of the ease of aqua and the underpinnings of the UNIX subsystem so they have expectations as well meeting all three of their needs i think is just the first step into creating application that not only will these people use but it will find uses that you may never have thought of what do Mac OS 9 administrators want mac OS 9 administrators they want to know what your application does before you even tell them what it does they want to be able to look on the screen and no intuitive ly what to do they want help in the form of tooltips or any other type of documentation on screen if it's not readily apparent to you or to them what their application does for OS 10 they want it to look like it belongs in OS 10 if it came from some other operating system user that other operating system was a previous magnet operating system and obviously if they're running it in Mac OS 10 and you brought it from some other platform they may be familiar with it should not require any learning curve hardcore units administrators of course want things like command lines and terminal windows and man pages and i'm sure all we heard this a million times over in there all there in mac OS 10 and as developers it's up to us to give them what they want because obviously that will make them accept this as a viable platform the question of source code comes up whenever applications are developed for any platform and I think the openness that Apple has given us the chance for us to give open source code out is another learning opportunity that can show more people how to write applications that will solve problems for their particular environments and there's maxell s-10 administrators they realize all of this they've steamed the light they understand what we're talking about they know the power that they have in front of them and they expect all these things out of a well written application if your application is not well written no matter how good it does what it's supposed to do they're probably not going to use it they want everything OS 9 administrators UNIX and administrators and and other Mac os10 administrators want from this application that you free aided the portability of your application pretty much requires that you've had experience writing this application on other platforms but if you have they expect to be able to use their skills and their scripts and their command line utilities that they've developed on other platforms with your application as well so the standards are very high for Mac OS 10 applications my own experience was with Arctic X and primarily the desire was to have an application that hit all of these goals and in the end gave us something that at the time did not exist for Mac OS 10 which was a way for us to easily move files across the network that was essentially our mission statement for our thing x we wanted to be able to satisfy these audiences solve this problem and then provide documentation in such a way that other people could look at what we've done and say for themselves is this something I want to use this relevant does this matter to me and even if it didn't matter to them it could be a source for them to look at in order to learn for themselves what it takes to develop software for the platform so when we take all the pieces that arts and X has become the main application the arsenic xcd and the package tools we see that we have all the pieces of a puzzle that actually was laid out before us long before we even knew that this was going to be the problem we were going to be solving and the problem was for us how are we going to get load sets out to these machines and have OS 10 on all of them and do it in such a way that our mac OS 9 administrators didn't feel afraid of making the switch so now we've identified these audiences and we've tried to say we're going to hit them we've worked on gathering input based on these audiences and that came from the web it came from hands-on experiences and face-to-face meetings and we decided that's the best way to make as many people happy as possible to create this development cycle and this development cycle would hit the three components of a typical Mac os10 application and those were the eunuch underpinnings the user interface and documentation short changing any of these three key pieces of the development cycle would lead to having unhappy users of your application and potentially who don't want to use your application so we can take a look at how each of these affects the final product that you're trying to promote there are three pieces to the Arctic X application in the arts and X project and primarily what we're looking at is a command-line utility which is the rsync terminal window application you can open up a terminal window and you'll see using our think dash dash version which version of our things you're running if it's the right one it will save it has hfs+ supports there's a GUI and the GUI is constantly under revision and as of 1.7 it's still not much to look at but it does what it's supposed to do which is allow a user to understand how this application works provides tooltips and generates strips that are highly portable so that other unix admins can see what you've done in this mac OS 10 environment and they can instantly recognize what you're trying to do and not only that they can use these scripts and their platforms as well so by creating the command-line interface the graphical user interface and providing documentation at places like Mac os10 labs org we're able to hit all of these key audiences the mac OS 9 users who were not familiar with this software can look at the documentation they can look at the website they can look at the GUI they can try to get an idea from that they can send email messages to us and we can talk to them and explain to them how to use this application the hardcore eunuch users get their command line interface and their UNIX command line tools and I get their man pages so they can feel comfortable there and if they've already learned how to use our think somewhere else there's no learning curve for them and the mac OS 10 users get the benefit of all of these things so in a sense they get the knowledge that can be used other platforms they get the ability to show OS 9 users how to use particular application and they can feel comfortable that yes this application fits all my requirements because I've seen what it can do and I can talk to the developer and I can feel comfortable that's going to solve my needs doing all these things as developers I think is crucial i just don't think there's any way around it i don't think there's any way you can take shortcuts to get to having an application that people want to use in mac OS 10 because all this power is there and if you don't use it if you don't explain how to use it your application won't be considered as viable but of course arts and x is just a work in progress and it's just a piece of the puzzle and it doesn't do everything if you needed to back up machines to local hard drives you can use arsenic x if you needed to distribute load sets across wide numbers large numbers of machines across the network you can use rsync x are there other tools that do the exact same thing yes so there are alternatives out there if you find them and they're more useful there's nothing wrong with using them either the idea here is just that this solve the problem for potential audience and it's up to you to decide how do i make my application do the same thing there's a lot of other discussions out there about things like comments like version tracker for example if you have good or bad press regarding your software do you like it do you not like it I said there's nothing wrong with bad press there's nothing wrong with having an application that people are making comments about good or bad because guess what that means they've tried your application they know whether or not they like it and they're letting you know what you need to change in order for them to use it so there's really no such thing as bad press and of course when you're developing your software i encourage you use the developers tool CD because the people at Apple have gone out of their way to create this machine that is viewed as a good neck a good cooperative Network citizen it's up to us to make sure it stays that way so now i think i'm going to let what car talk believe i'm done about migrating unix admin tools and porting command line tools thanks so if you went to the apple developer tools for unix this talk will look familiar to you because a lot of the same stuff is told in here so your sifted min and you have some applications that you have developed they're not shell script but they're actually application that you run so this talk what we're going to show you how you can bring your applications to Mac os10 easily and quite confidently that it will work on Mac OS 10 and it will tell you areas investigate what to do and where to look for information and what you need to do what you learn from this talk is supported ap is compatibility api's and some different ApS that may not be equivalent in other unix platforms or we have equivalent of those and it's very easy to port applications to Mac os10 because it is Unix so if you're unicast application runs on another platform it will be very easy so this is what your application will look like so you have the top layer which is your application you have libraries that you link in a frameworks which will expand later live system which is equivalent Lib C on other platforms but much more and then you have the colonel and the BS via the mark and the i/o kits available for you what you will need make sure that you do not uncheck the bsd subsystem when you're installing the OS and when you're installing the developer tools make sure you select vs vs BK and the x11 SDK so you could develop x11 applications as well so the toolchain is mostly new based so you have GCC GT BG make we also have BST make for transitional purposes only but G make is the default and you should be using that we have other tools like Xcode environment that you saw in the keynote interface builder and Malik debug for the logging and some other performance tools that you can use to tune your application there are three different compilers installed on Dracula stem three different versions of the c compiler so you have 2.3 3.1 and 295 the reason is we want to be able to target kernel extensions back to 10.1 so you need to use 295 and then for 10.1 10.2 we have 2.1 and for there are three ways you can select the compiler the best thing to do is just use GCC select that will set your compiler that you want and then everything else uses that or you can set the option in xcode or you can just call directly from the command line to be whatever koala you want before you're doing it yourself if you're porting an open-source application check porting environments according systems that are available that if somebody has port is already so there's Davenport's Fink and Mac OS 10 downloads on my apple site and if you do port it please submit a port to the system so that you have a large collection so the next person comes along has a application already ready to run porting script is very easy it's just the same tools that you have so you'll see shell pearl tickle these are all installed by default our shell is bash so you shouldn't be a problem there if you want to script GUI applications Apple script to your friend so the mic Mamluk will explain how he uses that quite easily so the end result is very easy to bring your scripts to micro Stan primary file system we use hfs+ we have many many file systems of my quest n the main one hfs+ has issued not issues but differences from the ufs which is the standard UNIX process some people use case sensitive is not their case preserving yes so when you type a file name with a certain case it'll preserve that but if you type the same file name with the different arrangement of cases then it will be the same resource Forks so Mac OS 9 people know what resource for Charlie and generally we have added journaling to hfs+ so it's faster and easier to recover our sink X also supports hfs+ so when you syncing files you can take resource Forks along with you the issues comes when traditional Mac users start using Mac os10 to tend to put fire spaces in filenames UNIX user know never to put files to use spaces soccer games always use extensions so Mac OS 9 users have type and creator code so they stick with that and then also some of the application use resource Forks so you'll have to worry about that and macro nice users are used to using aliases as opposed to links and for unix it doesn't quite know what to do with aliases so you have to be careful on that libraries on Mac OS 10 we have our own linker and the way we do our libraries it supports versioning plugins and you have we differentiate between bundles and libraries the extension for the libraries is delayed so if you use the dot SOS you have to be careful static linking is very rarely used so everything is pretty much shared frameworks I'll explain what frameworks are which is also available and live system which is a compasses lot of math lib lipsy and other libraries that just sits at the bottom so that everybody can access that bundles water bundles bundles are things that you put together and make an object so you can put execute executable code other resources such as Nash language translations and things like that or you can have multiple architectures of in the bundles and it's very easy you just drag one item in the finder to install and to an uninstall and examples are you have frameworks which are bundles and compound documents such as RTF D which has text and images and frameworks framework is a bundle where you have the actual library the headers the documentation other resources that go along with it so that you don't have to put your headers somewhere else in the library somewhere else they're all in one nice neat package and they can be moved around easily and they can be used system libraries are installed in system library frameworks where you should not install those because Apple reserves that place to install their own but you should install them in either / library frameworks network library frameworks in your of users home directory library frameworks or in the applications contents frameworks depending on how you want to expose the framework so it depending on how it's done a two-level namespace it's a very large issue or topic that can't be covered in this talk but it's basically how you access variables with same name at global space because we can have the same name in different bundles and frameworks so there's no collisions and things like that and it was default starting in 10.1 but you can go back to flat file name space if you want to but it's not recommended runtime issues if you want to save preferences system preferences you should be using open directory and if you want to save use it preferences then NS preferences and CF preferences their equivalent you should be using that and startup scripts we vsv never really had a good system to manage start scripts so we developed our own similar to system 5 and but ours is a bundle so it has the script it has the localization and and other documentation that you want to put in there and they're saved located in system library startups for the apple of supplied ones and then for you it's library startup items pre binding because of the speed that we want to gain from our linker we pre bind the symbols at runtime so that could cause a problem for applications like backup and security because they think it's the fireless change either you can't get access or you can't back them up so there you have to be careful about that authentication and authorization our system is rights based system so you give a right to a user to perform certain app actions and we have great app API is to go with that the Apple security framework is a good place to start Pam is available for compatibility reasons only so if you're bringing you don't want to change a code but CD art security framework based on CD sa is is a better way to go GUI options we have lots of great options coco carbon x11 and now cutie trolltech has made a dual license and open source and a commercial version so you can get a native mac OS 10 version of QT and use that as well for multimedia you want higher level mixed media cook time is the way to go low level karate oak or MIDI benefits is that's very fast it's very responsive and the cons is that you have to write your device drivers because you have to use io kit and onto I okay I okay it is the low level where you can access all your hardware and such as disks mice everything it's based on embedded C++ standard which does not there's few things missing such as rtti and multiple inheritance and things like that but it's a great blue design object oriented and it's very fast you only have to do your part of the code you don't have to worry about the other code that you have to write for device drivers if you come from other UNIX systems GCC 295 if you want to have the cash flowed on 10 1 10 2 and onwards internationalization up we have CF string and see if locale we which is recommended API and now Panther has wrt supported and you can use that but we would recommend that you use yes string and CF locale because we will bring forward new precompiled headers Jaguar had a problem with this but Panther has a new way of doing precompiled headers and it's much less of an issue than it was on Jaguar you if you have a problem that's the first place to start turn off precompiled headers and usually stuff works so to turn them off dash no CPP pre comp and don't use traditional because that's not recommend is deprecated even though it turns off need low p comp but you get the lesser level of GCC or c standard linker apples on linker it's it's a single pass so you have to put your libraries and free works at the end of your object files so you can get symbols lazy initialization of variables so it's really a problem for C++ so that your static initializers don't get called so you have to be careful there and it does pre binding shared flags not support e so you should be using that dynamic to make dynamic libraries so what's new in Panther we have W car if i convert ICU so all d its new but it's not recommended for you to use at this point because the binary compatibility but if you really have to use then you can use it it's ingress I oh yeah everybody was asking for that pole it didn't make it to this feed but it is scheduled to go in so in the final release you will have pole dlopen and dr close same it's scheduled to go in but didn't make it the dl clothes in deal open library is the lib compact which is available in downpours so in the meantime you can use that and ports manager GUI so this is large collection of ports that are available so this is nice gooey in the application utilities we just double click and see the list of applications that are available and then just say install and then you have that application available for is for GUI and command-line tools so that's it for me and we'll have Mike Bombeck come in and explain how he uses his applescript to thank you a car so what Kyra spent some time basically giving you some of the logistics moving your sis admin tools up to Mac os10 what I would like to spend some time on is telling you about how you're going to get Mac users to actually use them so let's face it Mac users via gooey in the UNIX world goo is a four-letter world word in in in the macworld goo is essential Apple has introduced several developer tools that that make this a lot easier package maker can help you with any command line tools that you use to distribute software they've got property list editor in there for configuring for editing any configuration files and then there's a some other tools like Apple script studio project builder interface builder for actually putting a GUI on to some of your command line based scripts and that's what I'd like to focus my time on is AB scripts to do Apple scripts to do and i won't get into all the various acronyms that people have assigned to it it's it's based on three technologies applescript project builder and interface builder I was introduced in Mac OS 10 12 so it's only supported on that OS and higher and it's implemented in the form of three project templates in project builder and there's over 30 sample product projects to help you get started coding in Apple scripts to do so some of this stuff is going to be fairly basic and bear with me but as much as this may go without saying it's sometimes important to actually say it developing a GUI step one is making sure that it works at the command line you want to make sure that all the functionality of your script everything that you want to get done is going to work in a shell script in the clan line environment how once you've got everything working for one particular scenario go ahead and generalize that shell script to make sure it functions in every possible scenario in your environment another very important thing to keep in mind is these are Mac people out here while Mac people are very very very intelligent very intelligent they are not unix savvy in general so you have to anticipate non uzak non UNIX user input like maybe spaces and past names and special characters things like that so anticipate non UNIX user input when you're preparing your shell script so once you have a shell script built and it's doing all of yours just admin stuff or whatever now it's time to go ahead and create a project and project builder there's three options you can make just a regular apple script application and this is the the most common thing you can make a document based application if you wanted to make something like a text editor or you can make a droplet application if you wanted to have the functionality of being able to drop files and folders on to the application and then have it do something to those files and folders after you've created your project actually the first step after you've created your project is to mock up your interface and interface builder now this is a very non-trivial step in the UNIX world you write a shell script it does something it may be ask the user to type in some text with the command line and as it's working maybe a dump some text out a GUI is very different than this you have many different ways that you can have the user give input you've got you know buttons and menu items and checkboxes all sorts of things like that and then you have different ways of providing output and giving people feedback as to how things are going so you need to think about how you're going to give feedback to these or you've got progress bars and dialogue windows and all sorts of things so it is very important to give the end user a really good experience and not just dumped out text or pop up a window and ask for text so once you've mocked up your interface you'll go back to project builder and then you'll attach parts of your scripts functionality to specific interface objects so in Apple scripts to do you'll use that du shell script function to just take up a particular shell script or just a particular command and attach it to an action like the click of a button one very important thing to remember here is GUI applications are not linear like shell scripts you're not just going to write up your shell script and plug it into a prescrip studio and away you go you're probably gonna have to break that script up and attach specific actions or specific commands to various things that happen within that user interface how you'll probably use global variables a lot more often because of that non-linearity so some of the other things that you're going to want to keep in mind our security issues that your script require admin privileges if so how are you going to get that password from the user is the admin user even the login user you're going to have to think about things like this if you just have one command that requires admin privileges then you can just use Apps Script Studios built-in functionality to retrieve the password otherwise you want to consider prompting the user for the password and storing it in a variable you also want to think about whether or not preferences would suit this utility well as Apple script studio provides as an object called a user default object that you can use and access to you can you can manipulate that object access a preference file in the user's preferences folder finally you really need to keep in mind you need to learn about your environment of environmental variables and your working directory don't just walk into this thinking that you've got the same working environment that you would at the terminal you don't even have the same shell there's actually a really nice tech tech info article I think it's called its number 2065 if anyone's interested in learning about how to work with D shell script and how it compares to the terminal environment okay so logistics aside let's go and move over to the demo machine alright so what we have here is you let's say that you're you're an IT administrator and your supervisor has just asked you with creating a software library you've got several hundred CDs and in the past they've just been you know thrown on a shelf or something and they get damaged actually could you take me back to the slides there was one slide that had all this up there sorry about that so you've got a couple hundred CDs usually they get chucked on a shelf and scratched or lost and a cds checked out so only one person can access it at a time you actually have to have one person that's assigned the task of managing that library and you'd rather not do that maybe you'd rather be surfing the internet so in the end it's just not a very good system so what you've decided to do is instead of sharing the actual physical disk you notice that in Mac OS 10 there's an extensive disk images framework and you notice if there's a really cool thing that you can do you can make disk images of the cds and then stick them up on your ex or running the apache web server and then you can host these images remotely and with just this little command right at the bottom you can mount that disk image remotely so you can host hundreds of images on your server somewhere and then people could remotely use this command and mount that disk image right there on their desktop and have access to it so now to the demo alright so the first thing you want to do is you want to kind of start out basic just create a shell script that implements that functionality so this is probably a bit hard to see so we'll just blow that up a little bit so you create a basic shell script that includes the path to that disk image or just one of the disk images you didn't create a hundred disk images you just started with one and you included that in the script and then the first thing it does is just mounts that disk image so we'll go ahead and run this script in the terminal and you'll see what happens it just mild flat disk image right there on the desktop and you have access to all the software there so it's a pretty basic concept obviously this is not going to be very scalable are you going to include the URL to all 100 or 200 to 300 CD images probably not so the next incarnation either side hey I've got a great idea i'll just have the user enter the URL this is great i'll never have to touch the script again they just type in the URL so why don't we go ahead and do that we'll run this script enter the path to Rupp half it's about a local volume or or was it so we'll just go ahead and type well pretend that I actually know what I'm doing I can / images / oh oh oh darn so you get the point obviously this isn't going to to be a very useful solution for your end users so ideally you would want to keep all of those the pats all of those images right there in your script so that's what we have here so in this script you decide I'll just keep the the addresses to all those images right here in the script and I'll present that list of the either ask them to choose one and then I'll mount the one that they choose so this is pretty cool for garden run this script so it presents a list 0 1 2 3 why don't we go ahead and pick number one and mom set disk image on a desktop so that's that's another thing you can try you realize though that's that's crazy I mean if I want to add another disk image to my CD library what am I going to do am I going to edit that script and redeploy to the 500 people that I had already deployed it to probably not that's going to be a maintenance nightmare and didn't we start this project to decrease maintenance in the first place yeah we did so being the clever IT guy that you are you notice when you set the indexes the indexes option directive in Apache and then go out to a web page and select just the image or the directory that the images are hosted in you get this nice little list of all the images dynamically generated by Apache if you take a look at the source you can see I can parse the heck out of that it's got a nice little tags right here I can use that as a delimiter and maybe I can do something like that as a limiter but hey this is cool because this dynamically generated a list of all the images in this directory why don't I just grab that list parse that list for the images present that list of images to the user the user picks an image I mount the image so why don't we go ahead and try that that's what this script is what we do is we just have the base URL in a variable and then we curl down the list that Apache generated index we's grep said awk whatever else you want to use and believe me I'm sure there's probably at least a dozen people out there that can do this maybe three letters or something but I'm not the guy but in the end you've got this little script that will parse out those image names so like this little bit wider we're going to run this script so you can see the first thing that it was really really very fast it curled down that index file and then it presented this and you can type like something like clear after this to clear that out makes a little prettier and then it presents that list of images so why don't we go ahead and choose number I'll call out number 90 yeah number zero like I said there's lots of people that could have done this lot better so and there we go it went ahead in mount of the image that I selected so in just you know what is that a dozen lines of code you've created it you the clever IT guy or girl has you've created this nice little script that will will read a dynamically generated list of disk images in monetary end user so now that we've got this script fully functional in the the command line environment we're going to go ahead and go over to projects builder and oh look at that there's already project-based made so create a new project and we'll go ahead just pick applescript application and call it whatever and in the interest of time I've already got all the detect entered but it'll create this have this project for you and the first thing we'll do is we'll go ahead and go into interface builder and mock-up and interface now this is going to be a very basic application I mean the only thing that we're doing we're presenting a list of images to the user and they're going to pick an image and they want to mount it so we really only need a couple interface items here I've got a table with my inspector tool thank you it's on by default in mine well go into the inspector and we'll give our table a name called the images or that's the view and then the table and then we've got just this other button will call it mount image and when this button is clicked we want it to do something in this the script right here so we attach some functionality to the clicked handler in the application applescript so this is really all there is to mocking up this interface just a table view and a button and don't say so we've got our interface mocked up why don't we go and go back to interface builder and take a look at the script now when you click on that check box and interface builder that attacked attaches that on clicked handler to that button it automatically generates some handlers inside of your Apple script so the first thing that we're going to do is instead of having to have the user actually do something to generate that list I just want it generated automatically as soon as the application is launched so we're going to use the on awake from nib handler and what it's going to do it will create how about we just do this look is that better okay it's not too important I'm kind of pretty much to talk you through it so we're going to dynamically generate the data source it's just a detail but then I've got basically two functions this extract image named function and then the populate table function so the extract image names function is going to use the du shell script command right here to curl down that dynamically generated index and then these some various stuff to parse out the information now wait you can see here I you said but I also use some apple script to do some parsing I honestly don't care I'm not a hardcore applescript guy that says i'm going to use apple script and use do shell script is very little as possible I'm not a UNIX guy that says i'm going to use octal day i die i use use whatever works and i found out that you know you saw that item 0 that was alt whatever i could not figure out how to get that fixed so i just decided to throw in from applescript and use that to help me do the parsing so this is actually a very nice tool in that you can mix multiple environments to get the desired result so in the end I just returned that list of images and then we populate that table so that's what happened on startup now I've got this on click handler and this is going to be very simple the user will pick an item in that table beyond click handler will determine the index of that item and then pull that whatever item that is out of the list of disk images which is kept in a global variable and then it will do shell script HDI you to amount and that particular disk image and then I provide some feedback because you're working in this application and something's happening somewhere else so I'm just going to throw up a dialogue there that says the image should now be mounted on your desktop so we'll go ahead and build and run this application and well it was really fast lot faster my powerbook so it the first thing I did was it curl down that dynamically generated index page parsed out that list present populates this table with that list of items and now the user can pick an item and why are we going to pick this one click on an item click on Mount image in which should now be mounted on your desktop so that is all there is to it so let's go ahead and go back to slides and you can get really fancy with this that was a very very simple example bah you can give very very I don't know what happened to my image but safe weekend give you an example what this looks like actually I think this is an older version yeah that's nice but you can get very very fancy with this and we'll just open up the nib file oh sorry could you switch back to the demo machine so like I said you can get really fancy with this you can create preferences good grief that's a really old version and you can throw in lots of functionality and make something so fancy that it can clone one just another that's that's one thing that I've done but this is a great tool and basically you can you can do just about anything if you use apples developer tool to put a GUI on your script and you can really extend it to too many other audiences so with that I think I'll go ahead and hand this back over to skip thank you we tried to make it fun try to present a wide range of information for system administrators coming from a lot of different areas these are some some more information obviously a good place to start if you're brand new to the platform gotta read inside maca with ten system overview the eunuch sporting guide is also an excellent place to start the tech note that Mike mentioned calling applescript from an application excellent and mike has the is offered the source code for the application he just demoed up on his website and he'll keep that up there for some period of time and there's the URL for that thank you Mike who to contact bringing over an application of some of the larger applications any place you get hung up or stuck that's exactly what developer relations is for in contact myself I'm the server technology evangelist with car Malik and developer technical support that's exactly what they're there for and Mike Bombeck has even relented to to be contact directly as well Kevin void at the University of Michigan's immaculate end employment coordinator should you wish to talk to him it's been a good week for you mission already I think Redmond d in fugu were both honored at the Apple Design Awards he's also remember the rsync X development team roadmap obviously some of these sessions have already happened so be sure to check them out on the dvds or Apple tools for the unix developer introduction to the tools swede GCC and debugging and then of course I think wealth of information at Mac os10 labs org yes and don't enter space that URL or you won't get a nasty surprise and obviously being an open source project you can find the source code to our sink underscore HFS that opened darwin dot org applescript studio sessions salsa going on is going to deliver a session called applescript versus admin that's really free willing he's going to he's going to go into a lot more detail about how to take really fun things you never thought you could do with applescript attaching very nice buoys to command line tools and with that I'd like to open it up to the Q&A you
