Configure player

Close

WWDC Index does not host video files

If you have access to video files, you can configure a URL pattern to be used in a video player.

URL pattern

preview

Use any of these variables in your URL pattern, the pattern is stored in your browsers' local storage.

$id
ID of session: wwdc2009-607
$eventId
ID of event: wwdc2009
$eventContentId
ID of session without event part: 607
$eventShortId
Shortened ID of event: wwdc09
$year
Year of session: 2009
$extension
Extension of original filename: m4v
$filenameAlmostEvery
Filename from "(Almost) Every..." gist: [2009] [Session 607] Using Servi...

WWDC09 • Session 607

Using Services in Snow Leopard for Scripting IT Tasks

Mac • 45:55

The power of IT is expressed not only in the management of systems, but in enabling others to do their jobs smoothly and efficiently. The dramatically redesigned Services architecture in Snow Leopard lets you put management tools at the and point-of-need and where staff and managers require them the most. Join the experts as they demonstrate Services integration strategies involving a range of standard computer languages and applications.

Speakers: Sal Soghoian, Steve Hayman

Unlisted on Apple Developer site

Downloads from Apple

SD Video (167.9 MB)

Transcript

This transcript has potential transcription errors. We are working on an improved version.

Welcome to the session on Services & IT--

Hang on. Wait, wait, wait, wait. We got-- I didn't talk to you about this. We have some leftover business from the keynote that I want to take care of. On behalf of Apple, I want to actually finish this demo here, so--

[ Laughter ]

[ Applause and Cheers ]

Everybody get your iPhone out, alright, get your iPhone out. Hold it up here and make a straight line. It would be great.

[ Laughter ]

[ Noise ]

God damn this is hard.

[ Laughter ]

[ Noise ]

[ Balloon Popping]

[ Cheering ]

[ Applause ]

I think this is the first session I've ever done in 12 years of being in Apple wehre I'm the sane one.

[Laughter] So you're in trouble, but thank you all for coming here today. I think what we're going to show you today is something really remarkable. You might not have heard a lot about it in the press, buzz or in the data sheets. But what you're going to see right now is definitely going to change the way you're going to work on the computer. You will not work on your computers the same way again after today, and you will be owned by us. Arrrr! [Laughter] So, I am Sal Soghoian and that is Steve Hayman and welcome to our session here today.

[Laughter] Yes, those are the same slides, OK. So this was interesting. It just came out, you know, yesterday we had our keynote and so, this is one of the quotes from Rob Griffiths in Macworld. "I think this may be one of the more exciting areas of change in 10.6 for it really turns Services menu into something that literally any user can take advantage of." And it is phenomenal what has happened here in the convergence of multiple technologies into a single point on your computer. I also want to show one other quote.

This one is from my Aunt Sarah, who [laughter] epitomized the whole point about automation, and this-- I run into this all the time. Everybody we're so busy in our lives that we don't take time to step back just for a moment to learn something that can actually move us forward. So, I want you to spend a couple minutes today, just step back from your busy life and invest a couple of minutes in absorbing this and making this work for you. So, we're going to talk about [laughter], so we're-- never leave slides unattended.

[Laughter] So we're going to talk today about delivering power at the Point-of-Need, and we're going to talk a little bit about that. And all of us who use computers know that computers are the most powerful for us when the tools that we need are nearby the things that we have selected, and are pertinent to the items that we have selected, so that they work on that kind of data and we're not bothered with other choices and other options that get in the way of our flow of thought. And we call this Point-of-Need, and you're going to see why in just a second.

So today, you're going to learn, these are the mandatory slides we had to do, changes in Service for Snow Leopard and using Services to manage networked computers, blah, blah, blah. OK, so we're going to look at this from a couple different viewpoints. One of the viewpoints we're going to look at is from the IT or the administrator's viewpoint of that you're actually controlling a network of people.

So we're going to say "Well, what kind of tools can we create that make it easier for you to do your job on this side of the screen?" And we're also going to look at it from the client's viewpoint as well, as to what kind of tools can you make that are going to make their lives easier and make it easier for them to do the right thing that makes the whole workflow work easier.

So these are the 2 viewpoints I want you to keep in mind. There are actually 3, but keep these in mind as we go along today. So, Services architecture has been around quite a while and it's basically the concept that if you have some information selected in one app, you can use the power of another app to manipulate that data and bring it back into the current app that you're in. And this technology has existed for quite some time in Mac OS X, and prior to that, in next step as well. And this is what we're going to be talking about today and what we've done to change this and move it forward.

So Point-of-Need, what is the Point-of-Need? Well, let's say we have an audio file selected in the Finder. And I'm a user and I want to take that audio file and I want to convert it to like an AAC high quality or an Apple loss list or something else.

So where do I go for assistance on doing that? Do I look over here? Well, do I look over here? Well, how about over there? Do I look up here? Well, if we look up there then we get all these nice menus but there's nothing on this menus that has to do with converting an audio file. So, let's look in the area around what I have selected and what my focus is on, and that area is what we call the Point-of-Need because this is where I need assistance, this is where I need my tools right here. My focus is on this point.

Well within that point, there is a menu that we provide that's called the Action menu. And this menu is contextual to a degree, in that it will change based upon the file or the multiple files that you have selected, but it really deals with file management kind of things that are gleaned from the Finder's File menu. So it's just the subset of those put in a closer location.

Convenience is nice but the functionality that we're looking for, for the audio file is not there. Well that's OK, because since the existence of Mac OS X, there's been this phenomenal technology called Services that has allowed you to change the name of any audio file from simplified Chinese into traditional Chinese.

[ Applause ]

Yes, the Services menu. And although many of you might look at it and realize that yes, it is a treasure trove of app functionality and goodness, it's been delivered in a manner that looks pretty much like a dorm room closet. Yes, the Services menu. It is pseudo-contextual in that some of the things that are grayed out changed to be some other things that are grayed out. It's not convenient, it's not configurable, it's not customizable, and it's just downright messy. But all of these changed when Apple made this.

Now, how is he going to make this bridge? OK. [Laughter] So with the smaller area to work with and one of these required as the input device, it made us rethink our whole strategy about delivering functionality to the user. So that if you do something with this device like take a picture, we need to figure out a way that we can provide some contextual functionality that's convenient to you, that gives you the power that you want so that you can do something like email the photo. It's a whole different kind of strategy. Point-of-Need tools like these are best functioned when they are contextual, they are convenient, they are configurable and they are customizable. When you have all of those, you have a really great environment to work in as a user.

Now on the phone, they are contextual and convenient but we can still take these concepts and apply them to the OS which is exactly what we did in Snow Leopard, starting with contextuality. So now, in Snow Leopard, if you have an audio file selected and you go to the Action menu, you actually see a service down there that has something to do with an audio file, right there where you need it at the Point-of-Need. If you have an image file selected, Services dealing with images will appear.

If you have an RTF file selected, Services dealing with them, if you have a PDF file, Services dealing with them will appear as well. So it is contextual based upon the kind of data that is currently selected. In addition, it's convenient because not only do you have the current Services menu that has now been reorganized and made much cleaner.

You also have-- [Applause] You also have the Action menu and an Applications Contextual menu. So in the Finder you have 3 different locations to get access to this as well. In most applications, you have a Contextual menu and the Services menu. In addition, we handle other kinds of data besides files and folders. For example, if you have text selected, we tie in with the Data Detector so that you can do things with text within a word processor. Or if you're on a browser like Safari and you control click, you can bring up Services that pertain to the selected text.

If you are in the terminal and you have text selected, you could even bring up your favorite Services for doing things in the terminal, because the terminal support is contextual Services as well.

Even in iChat, you can select text in your chat and bring up Services to do things whatever, you know, bring in import data URLs, those kinds of things into your conversation. So we've gone a step further, not only do we make them contextual and convenient, but now we've also made them configurable.

[ Applause ]

Woo! Yes for the first time you can now enable and disable your Services, and in addition to that, you can assign keystrokes to them so that that's the applause one right there, right.

[ Applause ]

So you can add your favorite keystrokes to whatever you want to do so you don't even have to bring up a contextual menu, you just type the keystroke and the Service fires off with whatever you have selected. And then one step further beyond that, we figured out how to customize them using the power of Automator. Automator that we introduced back in Tiger has grown and grown in functionality and use.

It is basically a visual way to construct a workflow by dragging different parts of automation recipe into an ordered pattern and then running that. You can save those as workflow files and then execute them. Well, we took this great architecture and we tied it with the Services architecture so now you can use Automator to create your own Service. This is our new Template Picker when you open up Automator and you see that Services one of the options.

When you select Choose, you'll get a new workflow with an Input Settings bar across the top. In this Input Settings bar, you can indicate the input data type, well are you working with text or you're working with files those kinds of things. Which application do you want to run this Service in, and do you want to run them in all Services or just a particular one. And do you want the results of the workflow replace the selection. So this really changes the way that you work.

And when it comes to input data types, we tie them with data detectors so we support the standard text ones of URLs addresses, email addresses, phone numbers, those kinds of things, as well as the standard file types, some are, you know, favorites audio files, movie files, you know, files and folders of those kind. And for those that use Remote Desktop, and how many of you use Remote Desktop? Whoa! Nader look, whoa, he's beaming, he's beaming. You are Nader's children, he's beaming.

[ Laughter ]

So what we've implemented here is that if you have Remote Desktop installed on your computer remote desk-- remote computers becomes a data type that you can select, so this means that within Remote Desktop, you can contextually click computers or computer lists in the Remote Desktop window and apply Services to them.

Woo! Steve is going to go crazy on that one, yeah you're right Yeah, he's frothing over there. So and you could also chose to have no input so that your Service just runs on its own, maybe does get some data from the web and brings it to you or whatever you want.

But basically once you've decided your input type and you just declare what kind of application you're working in, then you add Automator actions like you do to any other workflow. And because they are Automator actions, you can do things like show when run, and then when you save your Service, it automatically gets put into the Services' architecture.

So that when you have the appropriate data type or file type selected, your Service that you just created appears on the menu, you can execute it. And if you chose to have some UI appear, it will appear. You can then choose the parameters for applying the Service and then execute it on the selected items right in the desktop.

Yeah.

[ Applause ]

So, Services in Snow Leopard are contextual, convenient, configurable, and customizable. That's a dramatic step forward. And let me show some of them to you. So here we have 4 different kinds of data files in the Finder, in the folder, and I've selected I go to the contextual menu, I can chose rotate clockwise and it will apply right to the file in the desktop. If I select a PDF file I can encrypt it on the fly, if I like, OK type in the password.

[ Inaudible Remark ]

Yes, the password was Apple, that's correct.

[ Laughter ]

And if I chose the audio file over here, if I select the audio file, I can bring up and say like encode to iTunes audio format and pick the kind of format that I want like iTunes Plus and apply that to it right in the desktop, I can even take, for example, an RTF file and I can bring up the contextual menu and convert it to an HTML version if I like.

So you can see that having a tool at the Point-of-Need is really handy. My focus stays right there I don't have to open that file up into Preview, save it again as something else, do something else. I'm on my workflow, I'm focused on it. I can get my job done.

Now this also applies to other kinds of files. For example here I have an invitation for a cookout, it has an address, I can select the address, and the data detectors will sense that there's an address selected and it brings up the Just-The-Service for them [laughter] and I could say, who do I know near here in this address and it instantly tells me I got this friends of mine.

If you want, if this was actually connected to the web, we can draw Google map and bring them up. I did the easy way, OK. And if I have a phone number selected here, I can say, well, where is this area code, and have it show me where that area code is right in the Dictionary app, if I want to.

[Applause] Very powerful, very cool kind of things that you can do with Services available for you right at the Point-of-Need. So let's bring this back. So Services are contextual, the 4 Cs: Convenient, configurable, and Customizable. We've got that. So if you meet any press people, you go, "I must tell you about Services. They are contextual, convenient, configurable, and customizable.

You will write on this, yes you will." [Laughter] OK. So now, now that we've established basically the, you know, the story of Services. This was a little ground work for the few of you who might not have remembered the tragedy that was Services. [Laughter] Whoa! Whoa! That was brittle. OK, so let's look at how this pertains to the world of IT.

Well as an IT professional, you're always-- it was supposed to go that way. You're always, you know, you're dealing with, you know, setting up administrative computers. You're managing network computers. You're creating assistance tools for clients. So, you know, you're doing lots. You have many different roles and these are 3 of the viewpoints that we were talking about earlier right? How can you use Services to help you when you're, you know, administrating your own computers, you know, what are the kind of things that you can do with Services? Can you better integrate it with the Finder so that, you know, you can just select something in the finer run that run the shell stuff on it right there. Is there a way to extend what the terminal does now that we've seen that that is contextual as well. Is there a way to gather data about your network and about what's going on and then put that into like a report or something like that, you know.

These are the kind of things that you use on your own machine, not necessarily managing somebody else, but just for yourself. Will Services play a role there? In addition, if you are in a scenario where you are managing other computers, how can Services be of assistance to you there? I mean, for example, is there a way to automate classroom setup and clean up software installation, any kind of thing dealing with Remote Desktop or managing multiple computers, you know, doing an SSH into a computer or something like that.

These are the kind of things that you can now put under your fingers or put under your keyboard command using the new Services in Snow Leopard. And then finally, what are the kinds of tools that you can make and distribute on machines that make it easier for your clients to cooperate, to be good citizens, to do things correctly.

For example if I was in a classroom and I wanted them to turn in their homework, could I make that a simple Service that they could just select something and the file would automatically check into the server correctly. Those kinds of things. So we're going to look at that now and I'm going to get out of the way and let the madman go to work.

You might not know it, but you've been watching Services in action at WWDC all week. It might surprise you to know that not everybody at-- not every engineer at Apple is the phenomenal typist that you think we all are. People seem to be typing things awfully rapidly in their coding demos. I don't know if you've noticed that but that's actually a Service.

We have an internal tool that you can't have that's attached to a Service that types things like this, and you can look like a much better typist than you actually are. So that is a Service that has been around for a long time and it was written in Objective-C and that was hard. My hats off to the guy that wrote that Service. It's the one that we all use in our demos. But Services used to be hard. They used to be hard to write. In fact I remember when they were-- when they were really hard to write.

I haven't done--

[ Applause and Cheers ]

You're going to have to, you know, to bear with me. I haven't done the NeXTSTEP 3.3 demo in, you know, 15 years. I hope I can remember which mouse button I'm supposed to use. [Laughter] But back in the day, back in the day, there were some pretty cool Services that shipped with NeXTSTEP.

One of which I happened to like was a tool that would let you take a document for instance, you could choose a file somewhere over here in the documentation and I can't edit these files. I'm not root, I'm an ordinary user logged in here. But we had a service kicking around that let's you click on a file and say Services "open sesame, open as root." And what that would do would be to ask you for your 15 years ago root password, holy mackerel [laughter].

Oh, it's the same as today, yeah, OK. [Laughter] So this is actually launched back on next tip. This actually launched another copy of TextEdit but it launched as root. I have been pining for this service on the Mac forever, and I'm going to write it in front of you. Well no, I'm not going to write it, I'm going to use one that I wrote back at home.

But first, I'm just going to refresh my memory about this-- this was a pretty cool service, this open sesame tool would do that. And now who wrote that? Oh yeah, I wrote that, yeah. [Laughter] [Applause] I wrote that with this other guy. I don't know-- now stop. I don't know what happened to the other guy. How's he doing? Is he still around? [Laugher] But, he helped me. The names are in alphabetical order.

Just for the record, they're in alphabetical order. But you can have Services like that today, running on Mac OS X. And they're easy to build with Automator. Automator lets you create a brand new service, and thank you to the kind of folks at VMWare for letting me run NeXTSTEP on here.

But Automator lets you create a service really, really easily. So I happen to have on here, some other files that I can't edit, but I could use my different key now. I could Control-click on this and have a Services Menu that actually opens, this thing as root. This is a little AppleScript application.

It's going to prompt me for my root password, and wait a minute, yeah, yeah, yeah. And that's actually launched another-- it's figured out what application owns this file. And it's used AppleScript and do shell script with administrator privileges to open another copy of that application as root. And I can now edit this file and completely change the documentation on the system to suit my whims, and to put my name first on the list. So [laughter] these things turn out to be particularly easy to write with Automator. I want to try and write a few from scratch here for you.

Let's see, so how about this, let's make a service for the Finder. Let's make a new service that's going to take, you start up Automator here, you say you want to make a service, and what do you want the input to be? Sal mentioned this before but up at the top, you say, what sort of input is this particular service going to take? I want one that takes the selected folder in the Finder, and then that's the first action of your Automator Workflow. Whatever comes next is being passed the Finder's current idea of a selection.

So I'm going to toss in a little bit of AppleScript here. One of the great flexible Automator actions of all time is this one here, run AppleScript. This will actually run locally an AppleScript that will be passed the Finder on a previous action. And I'm going to do something that's been-- I've been wanting for a long time, tell application terminal to activate, to come to the front, and then I want to do this.

I want to cd to that folder

[ Inaudible Remark ]

Yeah-- no, I did close the quote. Alright, alright. [Laughter] I would have got that in a minute, alright? You're leaping ahead. Coded form of, this is always fun, POSIX path of item 1-- of input, this is a very wordy language though, have you ever noticed this? [Laughter] Of the input.

Of the, the, the input, 'cause you can do that, and not now. [Inaudible] So anyway, what's this going to do? What's this going to do? Here's a little quiz. This is a thing that's going to take the selected, oops, do shell, do shell CD quoted form of, yeah-- no, no it's not do shell. Do shell in terminal 'causes it to open a new terminal window running this command. Do shell script, that's a different thing. I've done something else.

We may do the Graham Kerr trick of switching.

[ Inaudible Remark ]

The what?

[ Inaudible Remark ]

[Inaudible] thank you, thank you. I'm so glad, you know, I'm so glad we're having this rehearsal. We don't usually have this many people come to the rehearsal [Laughter].

You know, we always rehearse a week ahead, and then next week, you're all coming back. It's going to be great. It's going to run like clockwork. This is fantastic having an open rehearsal. We should need to do this more often, would you please take note of that. Thank you AppleScript experts in the crowd. So if I save this thing, and I get to give it a name, this is going to go hide in my Library Services folder, new terminal window here.

Now, I've got something where I can pick some folder in the Finder and I can Control-click on it, maybe I've got a little, oops, that's wrong, I got it, no, no, no, no. New terminal window here, that's going to launch terminal and CD me over to that folder.

[Applause] Please, no, no, no, no, no.

[ Inaudible Remark ]

What?

[ Inaudible Remark ]

What? What about a keystroke? Gosh, Sal that's a fantastic idea. You could put a hot key on this. This is something that you thought you were going to be doing all the time, over here in the Keyboard Preferences pane, you have all the available Services and you can enable and disable them, and then you can pick one you like and this is the greatest thing ever. You can attach a hot key to it. And in fact, you can have a shell script or AppleScript that doesn't do anything to its input like an arbitrary script.

So long as it's sitting in the Services folder, you can hang a hot key off of it here and expand your massive typing ability to run arbitrary scripts. So if I can find this one, which I just created here, what did I call it? I can't remember it. New terminal window here, dum dee dum, dum, this would be one that works with the Finder. These are contextuals, there's one of them here, says, new terminal window here. Yeah, I want that one, and I want to add control option command key.

How about that? That will be my hot key. And now, wherever I go in the Finder, whatever folder I happen to pick, you know, pick this folder here, this guy's folder. I can go control option command key, and we'll just try it one more time, and maybe just avert your eyes for a moment here. We're going to go like this, and we're going to go do this, and this doesn't do anything.

So there's no point of telling you. So [laughter], I've blown this one here, dum dee dum, dum. How did I mess this up? I'm not that hosed, a new terminal window here, folders in Finder. I'm going to go back and do the remainder of the demo in NeXTSTEP. I think that would be more [laughter], more exciting, you know what, you know--

Drag the folder on the terminal.

"Drag the folder on the terminal" -- No, I know you can drag the folder on the terminal.

[ Laughter ]

[ Applause ]

Alright, I don't really want to put a terminal hot key on this one because I got better ones I want to put terminal hot key on. My favorite program, and apparently yours, judging by the response, is of course Apple Remote Desktop. [Applause] Are you happy, I mentioned it? Are you happy there, Nader.

So Apple Remote Desktop also supports the idea of a Services Menu except in its case, it's taking the selected computers, and passing them in to your Automator action. So you can now write a workflow that where you choose some computers in Apple Remote Desktop, and then you have a context menu where you can run your script on those computers. Automator already comes with a whole bunch of actions that are designed to operate on a list of computers. But you can write your own as well.

And since I was so successful on the last one, we're going to try another one here. I want to do a minor variation on that kind of thing. I want to make a service where we take the selected computers in Remote Desktop and we're going to run a script that launches an SSH session to those computers. That would probably be a useful thing.

I have a list of computers coming in here, repeat with a computer, and we're going to do several computers at once, and input. We're going to try this, tail application terminal. This is really me typing, not typing a hot key. Activate, do script SSH Apple at the internet address of a computer. We're getting passed objects from Apple Remote Desktop. And we're building a little loop here that's going to tell terminal to essentially go and find the IP address of the computer that just came in, and create a new SSH window here.

So I'll save that new SSH window. Cross my fingers and as many other body parts as I can cross here right at the moment [laughter], pick one, and new SSH window. Oh, how do you like that? There you see. It's doing SSH to that computer. [Applause] And it's doing SSH to all 8 of them, right? It will take all 8 of them there and do 8 [laughter] SSH windows for you. These things are pretty easy to build. I mean, Automator gives you this whole infrastructure and it was a lot.

Trust me, it was a lot harder back in the day to code this kind of stuff up with Objective-C. So, I want to try one more relatively elaborate ARD one here, 'cause I'm feeling a little cocky because that one-- that one actually worked. You could build workflows out of the existing Automator access but that's no fun. I want try to create something new. Here's an example of a kind of thing I do all the time.

I pick a computer on a list and I fill this in, send UNIX command, host name. Alright you know, something that I want to do and I want to run that as the user root on this computer, and then ARD runs it an it puts it in the window and I go, oh, yeah, OK, there's the hostname, when in fact, they want to do the hostname on all the computers. So I do it all over again here.

I do all this clicking. And then if I want to do a new command, I edit it again. I wanted to speed this up a little bit.

I am running commands on a list of computers all the time. If you're like me-- you're like me [laughter] you've been oh, come on, you've been waiting a long time for the Bourne shell to rise the position of prominence as a Mac programming language that it has needed, right? This is been a long time coming.

If you put the time into learning the Bourne shell in 1975, and you haven't been bothered to learned anything new since then, this is the tool for you because you can now apply scripts to these things. So I'm going to do-- I am going to attempt to build a little script here. Let's make another-- another Automator action here.

This one is also going to take a list of computers. A list of computers and Remote Desktop and-- I'm going to slum it a little bit and do another AppleScript here. Now there are two AppleScript things in Automator. One of them for Remote Desktop runs the script on all 8 selected computers out there.

I want the one that runs a local AppleScript on this computer here, because here is what I'm going to do. We're gonna do this. We're going to say tell the application Remote Desktop. It's good, you know, put end in there while you're doing it, this is good style. We're going to tell it activate.

We're going to tell it display dialog, what command do you want? Default, answer. This is how you in AppleScript prompt for a string of text. Set command to text returned of the result. Now I've determined a command that the user would like to run. I would now like to execute this command on all 8 computers. Said T to make new, send, UNIX command task with properties, name, run this. This is me creating on the fly a new send UNIX command in Remote Desktop.

The script I want it to run is the command that we just typed and the user we want to run it on-- now this is dangerous. Now just be careful. We're going to run this command as the user root on all the computers and we're going to say execute T, that's our new task, on input which is all the computers that just came from the previous action.

Alright, on input, pardon me. Yeah, it already flowed. I'm going to be real careful here, believe me. So this is a script that's going to prompt me for a command and then execute it on a bunch of computers. Run something dangerous [laughter]. And this might be not a bad time to go and add-we'll a hot key to this one too [laughter]. Running with scissors, I should have called this one here. So run something dangerous-- yeah [laughter].

What was that command shift U you for UNIX tool? Good idea, yes, we'll do command shift U. So I've got a hot key now that will run something dangerous here on all these computers. What command, date, ohh, that was good, OK. There. So there's all the output. You know I maybe want to do another command. Well command how full is the boot disk. Well there it is, here's all the output over here. And we'll run another command, rm-r~Nader [laughter].

Oh, maybe we won't do that. So this is a-- I think a tremendously useful tool by which you can take the kind of workflows you do every day and stick hot keys on it. You can sit in here for a Remote Desktop and just type-- type commands all the time and they're suddenly being spread across all these different computers.

So these are some examples that Sal and I discussed of scripts that might be very useful to the computer user. But what we are doing now? I'm so excited that 2 out of 3 worked.

So we were looking at different scenarios?

Oh yeah, that's right scenarios.

So we're looking at from the administrator's point of view of what kind of tools you can make on your own machine to make it easier for you to do your job.

What kind of tools can you do to make it easier to manage computers--

Yeah.

As you kind of stepped on.

OK, I'm with you, yeah, yeah.

And then what kind of things can we do that make it easier for your clients to do their jobs?

Are there any workflows like that, Sal?

Yeah.

So, well, let me show you a simple one--

Alright.

[ Laughter ]

[ Applause ]

That was amazing.

Undo everything I just did.

Undo everything you just did. Yeah, right.

They're actually--

We do have a panic script for that.

That was a good question. He actually asked if there's a script for that but, yeah, that's a good question. So here's one. I'll show you my UNIX prowess.

Here's a simple idea. I'm in text edit-- I have a list of names. Even though it now supports all the wonderful transformations and substitutions and everything, you still can't sort the text that's selected. So I'm going to make a simple sort tool that my clients can use to sort text.

To do such a thing, I just go to Automator, I'm going to choose Service, and I'm going to take as input text in any application and replace that text. I'll do run shell script here and I think there's actually-- this-- I had a bet with Steve as to what the shortest command I could possibly use. [Voice over] Look at Sal typing a shell script.

[Cheering]

There we go, that sort, OK and then I'm going to save that as.

[ Inaudible Remark ]

I didn't do it in the AppleScript going do shell scripts. So that was good news here. Sort selected paragraphs. OK, and now I can close that and then I'm over here and I should be getting that soon. We have the crowded Services menu here. OK, and sort selected paragraphs is right there.

Voila!

[ Cheering ]

So this is a classic example of if I can do it, you can do it kind of story, right. They always bring up the pathetic person who doesn't know how to tie their shoe to do the simple sort command. So, that's one example of a kind of tool that you can use with your clients. But we have one here that we're going to show and I'm going to need assistance on this. So this is our classroom of students over here.

Let's move some of this stuff out of the way, and that, and that, and that. And this is our class room. And they all have homework assignments and we want to be able to have an easy way that they can check in their homework assignments and I can see when the assignments are coming in so I can get them, so that they don't leave the class without turning in their homework assignments. And we also have a folder here that contains folders for each one of them and what we're going to do is do we have assistance here, somebody, Sean, somebody. We need you to check in your homework.

So what he's going to do over there is I'm going to do, you want to do Sean. So hold on, hold on. Let me make these windows so that we can see the results. So Sean is there, Sean is over here, Sean is everywhere. OK, so we're watching Sean and he's going to select the file and he's going to run the service that we call check in class work. If you want to check in your class work and it mounts it and copies it across.

[Humming]

OK, no homework today. Everybody gets an A.

And what's happened? Oh, what's happening? Leave it alone. There it goes. Done.

[ Inaudible Remark ]

You'll notice here that we had a folder action on the Sean folder so that once the file gets in the folder, the folder gets turned green and we can see that Sean did turn in his homework.

[ Applause ]

Sal, I have a second balloon ready just in case.

I almost needed the balloon for that one. So these are just, you know, some of the simple ideas that you can come up with for manipulating data on their side doing things that are helpful for them as well.

And I think that I have, let's see, if I have that and-- see, did it pull it up. Oh no. And nope we've used the wrong one, hold on.

OK, go ahead.

Go here, you out of the way.

[ Murmuring ]

Get out of my face, decide later, leave me alone, go away. Geez, what are we like Microsoft here? What is this thing? [Applause] OK, I'll be paying for that one later.

So here's a couple of photos that I have selected of some people I met at conference, great shots and I want to share them too with them so I go up to the iPhoto, choose Service for that and oh no, the Service didn't get installed, OK. Sorry.

[ Inaudible Remark ]

No. Hang on. OK, now I'm determined.

[ Humming ]

Hold on.

This is worth it, this is a good one. This is worth it. Isn't it?

I'm hoping.

[ Laughter ]

We've got 33 minutes left, Sal.

I hope I got the Services, nah where is it?

No, it's not Apple.

[ Laughter ]

OK. Did I install, did they install? No! I didn't install the Services. OK, sorry. Sends, it figures out who's in the photo, sends this email photo to everybody. So as punishment for that I will post these for you guys to use yourself and get them. [Applause] So let's go back to the slides here.

Why not.

Alright.

Ah. Argh! It's a killer demo too. So what can you do to advance Services and to use them more? How can you take it to the next level? Well the first thing that you've seen is the run shell script action. And it's a really great one to use because it has all of your favorite shells in it as well as also support for perl, python, and ruby. So you can create workflows that contain series of these actions linked together and do whatever you like to do that's insane and crazy or just actually productive.

You can also use the run AppleScript action and now with Snow Leopard we've introduced something new with AppleScript. It's called AppleScript Cocoa or AppleScript Objective-C. It's got a couple different names but basically within this environment and within Xcode AppleScript can call any Cocoa framework call that you want to make at all directly from within the language, so.

[Applause] So not only can you call the shell using the do shell script command, now you can just get straight at any Cocoa call that you to do, anything Objective-C can get at we can get at with here. So you can combine these as a way to extend your abilities using Services.

Also, you can make your own custom Automator actions as well. For example, you can create actions with different templates, you can create a Cocoa-based action if you want to write your run code in Objective-C. If you want to write your run code in shell you can use the shell template and create an Automator action that's in shell or you can use the new the Cocoa AppleScript template and create yourself an AppleScript-based Automator action as well. And how do you publish your Services? If you have an app already and you want to take advantage of Services there's a couple things that you can do. One is that you can learn how to publish it.

There's a session coming up here, 109 Pasteboard Services and Interoperability on Thursday at 2 and Peter Ammon was nice to loan me a couple slides that basically explained that you declare the Services in your app's info.plist, the Pasteboard server reads that and then publishes it to the menu. And within your plist this is basically how you declare this kind of things using these various tools and objects here.

In NSMessage your send types, what kind of data you're working with and then whether you want it to be there even if the selection is empty. So go to that session and learn how to publish Services for your existing app. Another way to make your app take advantage of Services is just make it scriptable and then people can write Services to your app using your app for anything that they want to do.

There is a Scriptability Lab on Wednesday at 12 that you're going to want to attend if you're interested in learning how to make your app support Apple events. So summary, we've seen that Services in Snow Leopard address the Point-of-Need. They deliver power right where you need it, when you need it and they are contextual, they are convenient, they are configurable, and they're customizable as well.

For more information, don't contact Matt Drance. Poor Matt, he's overloaded with a bunch of stuff anyway. I want you to go to macosxautomation.com. It's a great website, new website, and it hosts AppleScript and Services and it hosts Automator. Complete sites for each one of those. In addition we're going to have a new site going up shortly, macosxautomation.com/training. If you're learning-- interested in learning any of these languages you can watch videos, learn from them and you can take tutorials and classes on that as well. And that's macosxautomation.com/training and macosxautomation.com.