Information Technologies • 37:15
With the addition of Automator support in Apple Remote Desktop 3, system adminstrators can streamline time-consuming administrative tasks. Discover the 30 Automator actions included with Apple Remote Desktop and see how to construct Automator workflows to reduce your routine management tasks.
Speakers: Tony Graham, Steve Hayman
Unlisted on Apple Developer site
Transcript
This transcript was generated using Whisper, it has known transcription errors. We are working on an improved version.
We're just going to go with this simple action just like this. And I'm going to choose Show this action when run. And in Automator, that will pop up, that little piece of the UI, when this thing runs. Let's save this. But not in the usual way. We're going to say save this as a plugin. And we want to save it as a folder action.
[Transcript missing]
Uh-oh. That never happened, did it? We'll quit Automator right now and we'll find a file, we'll drop it in there. Somewhere I've got something interesting on here. How about...bear with me for a moment. I had a movie I was looking for. Put the slides back up for a moment.
Thank you. All right, hang on. We'll be right with you. Tony, tell them a joke. Oh, my. I'm the straight man, Steve. I know no jokes. There's this really cool movie at the beginning of the presentation. I can switch to that if you want. Yeah, go to that one. Everybody wants to see that one again, don't they? So how about that party last night? Wait, no, I'm ready, I'm ready, I'm ready, I'm ready. Okay, here we go.
Okay, now can we have this machine again? I found my movie. I'm going to drag this file and I'm going to drop it in that folder, and that should trigger an Automator workflow that pops up this little piece of the UI, which is optional, and I'll say copy this to all the computers, and it should copy that QuickTime movie over to all the machines and launch it and play it.
So you've now got a nice little way that you can distribute something easily to all the computers in your lab. You've got a little folder in your desktop, drag and drop stuff in there, poof. It appears in the lab. I noticed something interesting. Picture you're a teacher with a room full of students, and you're looking at some interesting web page. Here's your Toronto Argonauts finest team in the Canadian Football League website.
All right, all right. You can drag a URL out of here and drop it in that folder, and it will copy some kind of a web location folder over to the other machines. And they should all then go-- This workflow will wake up and copy that URL to all the remote machines, and they should all open this page.
That's going to be... So for me, I had that one set up to pop up that little piece of the UI where I could pick all the machines. But you might like to set it so it just automatically dumps things to all the remote computers. I got one more slightly elaborate workflow that we showed yesterday I want to give you a brief peek at here involving some custom actions that I wrote. I've got a workflow here called Classroom Quiz. It's my other teacher's scenario. How many of us are frustrated teachers? How many of us are teachers' college dropouts, by the way? I'm proud to be a dropout of Teachers College at York University. Thank you very much.
Here's a workflow that's going to, we did this one yesterday, but I'm going to talk a little bit about it today, that starts out by making a new keynote presentation. And then we're going to take a computer list, find a bunch of computers, and we're going to run this custom action, which is a little AppleScript Studio-based action here called Ask a Question.
This action is going to pop up a little dialogue on the nine computers, and my lovely helpers over here are going to vote on the answers. They've got 10 seconds to pick a choice off of this list. And then the results come back in here and are passed to a standard Keynote action that adds a chart to a slide, in this case a 3D pie chart. So I'll set this one to Show Action When Run, and we'll run this here.
So it's making a new keynote presentation in the background. I get to fill in my question. Who's your favorite CFL team? The Argos, Hamilton, Montreal? Okay, guys, go vote. So they all get a little pop-up... Little pop-up like that on each of these computers. They're all voting, picking one of the buttons. The answers are coming back after a 10-second timeout. The data is passed to Keynote. Keynote makes a pie chart with the answers.
Isn't that neat? There were a few too many votes for the Montreal Alouettes. I think we're going to have to do this one again. Get back up here and vote for the right team. Holy smokes. Stop. Even when you rig the election, apparently your team loses. Ah ha ha ha ha. Jeepers creepers. All right, Tony, do some slides. That's how you feel. Sorry, that was my one joke.
All right, so that was Automator. We'll loop back through and show you some of the things you can do with AppleScript. And for those of you new to AppleScript, you want to find applications that have dictionaries. And the dictionaries will tell you the kinds of things, the objects that you can interact with in those applications with AppleScript.
This is the dictionary for Remote Desktop. And in it, you see things like common tasks that you might want to run. Here's a list of the task objects included with ARD. And we can do things like send Unix commands. We can restart the machines. We can lock their screens. We can install packages.
Let's take a look at a very simple example of a task, the upgrade clients task. So you set up a bunch of machines out of the box. They have the ARD 2.2 client installed on them. You've got Apple Remote Desktop version 3. You want to upgrade all of those clients to 3.0.
We've got an Apple script. The very first line here is going to create a variable called the clients. And in this variable, we're going to stuff a list of all the computers that you have selected, that you just selected in Apple Remote Desktop. And that'll remember those, and then we'll create the task as a new upgrade client task. And finally... will execute that task on those clients.
And because we're telling Apple Remote Desktop to do something, we'll actually see those things happen in the application as if we'd done those individual tasks with our mouse and keyboard. A more involved example is the send Unix task example. And in this case, we want to run the Unix command uptime. We want to see how long these computers have been running.
Still very simple, but we create a variable called myserverlist. And notice in this one, instead of picking the machines that are selected in Apple Remote Desktop, I've predefined an ARD list called servers to run this task on. And I created a new task. I called it anewtask. It's a sendunix command task, but notice we have a lot of properties we can set for this task. These are options that you would be clicking in the application if you were running them manually.
Things like setting the name of the task. ARD will remember and show you the currently running task or previous tasks. This one will be named showComputerUptime. We can also decide when we run this remote Unix task which user it will run as. And if you want to run a task that requires administrative privileges, you want to choose the root user.
The root user does not need to be enabled on those remote systems. ARD will run your script as root regardless. Finally, there's ordinarily a checkbox in ARD to show the output of your Unix command. In this case, this is something we want to see. And when this executes, ARD will perform this task and show you the output within ARD. And finally, the specific command that we're going to execute is uptime. It could be as involved or as simple as you like.
We're going to execute the task that I defined on the machines in that computer list. But in addition to doing that, we're going to create a variable called the result, so that we can get those values back and maybe do something interesting with them. And this is what those results look like in this case. A number of machines will respond with their unique ID, their IP address, and the results of that command.
If you enter that script within Script Editor, which is in--it's included with Mac OS X, you can save that as an application. And it resides in your finder. Double-click on it. You can also trigger it as a result of things like mail rules. So let's say your boss sends you an email message that says, I'd like to know what the server uptime is.
Your script can fire, get the uptime, potentially mail it back to him, and he doesn't even need to know you're not at work. And then we've also got iCalc capability. So if you want to schedule scripts without using something like Cron-- Just put them in your calendar, set an alarm, and have that alarm trigger an AppleScript. And now for some more AppleScript demo, here's Steve Hayman.
[Transcript missing]
Now, I want to just, before I proceed, I want to show one little Unix command that I wrote here that I'm going to be making some use of here. We were at Macworld. Nader and I were at Macworld back in, when is Macworld? It's in January or something. It's not here either, is it? Is it here? It is here.
It is here. And there was some big, humongous lab of iMacs spread all over the place, and something was wrong with host 47, and nobody was really sure which machine was host 47. There were 50 computers out here. Which one is host 47? I thought, well, there's got to be a way to identify that from across the room. So this terminal window here is running on my laptop. I wrote a little tool called Big Honking Text. that just displays text in big letters on, sorry, on the wrong computer, big honking text.
This displays text on this computer here like this. And if I could send a command like that to a whole bunch of computers, then I could display large text on a whole bunch of computers. People say, "Steve, why didn't you use Growl?" Well, Growl is great, but I think Growl requires you to be logged in. This particular tool can display text on top of the login window, which is kind of nice if you have a bunch of logged out machines. So I got a tool like that.
That just makes me want to write a script, you know? So we're going to bring up Script Editor here. We're going to try to create a new script, typing it from scratch without using any of those wussy type-it-for-me tools that some of the other presenters have been using this week.
and I are going to tell Remote Desktop to do something. First thing I want to do, I want to create a computer list. This list happens to be called WWDC over in Remote Desktop. You can see I've got a list called WWDC with these nine machines on it. Set WWDC to Computer List WDC. And if I could just run that, you can see that we've retrieved some goofy kind of Apple script reference or something to a list of computers inside of ARD itself.
Now I want to create a Send Unix command task. If you look over in the dictionary, You'll see that there's this class called "Send Unix Command" - "Send Unix Command Task" - and you give it a script and you give it whether you want output shown in Remote Desktop or not, and you give it the name of a user you'd like to run the command as. Perhaps the console user, but perhaps root if no one's logged in or if you want to remove all the files.
So let's make a new task here. Set my task to make new send Unix command task with properties. Is this the most verbose programming language in the world? Name. I'm just going to run the Unix command hostname as a simple example. Hostname. So this is going to be the name of my task.
The script it's going to run is I'm going to run the Unix command hostname. Okay, that's just a command that returns the hostname. We'll say showing output true. That means I want Remote Desktop to display all these results. And user root. Don't really need root for this. So that's actually created a task object now. I've got a task object. I've got a computer list. I'm all set.
Execute my task on WWDC. Running this will execute, will create a new Send Unix Command task and run it on all those remote computers. And this isn't going to display anything on the screen yet. This is just going to return results to me here. So if I run this, we'll see that ARD has actually run it over here. It's shown the results.
And back here, I get this complicated record with the line of output that came back from each machine and their IP address and so on. If I want to, in Apple Script, I can walk my way through this and start picking out results and analyzing them. And doing more things to certain machines. However, given that I have a program called Big Honking Text, Let's change the script so that it pipes the output of hostname into the big honking text program on each of the remote computers.
and I hope you can see it over here in this window over here. We run that now. Each of the machines is going to display their host name in big letters. This starts to get pretty handy, I think, if you're trying to diagnose things on a large lab full of machines.
So one approach that you could take is you could write a whole lot of these little system administrator-y kind of scripts that ran Unix commands on remote machines and displayed them in big letters. And then you could walk back to your computer every time and launch the script or run the Automator workflow or run the Cocoa application that you built with all this.
I'm lazy. I want to run it near where my computers are. There's this great tool called Soling Clicker. Those of you with Bluetooth phones, you should get Soling Clicker or one of some other similar applications that allow you to associate Apple scripts with events on your phone. Soling Clicker runs as a preference pane like this.
and the idea is that you can set up your phone, a link between your phone and Sol and Clicker on this computer to execute an Apple script. And why not have that Apple script execute a command that tells Remote Desktop to go and do something? Now we're talking. So if we dig around in here, I have set up on this system a bunch of ARD scripts.
Here's one that shows the host name. In fact, if we looked at it in Script Editor, this is just a simple script, just like what we saw. It's displaying the host name on the remote computer. But Sol and Clicker is associating that script with an entry in my phone. I think I can show that to you here.
If I hold my phone up to my iSight camera. One second. Oh, I have a message. Oh, great. No. One moment, please. Steve, you were supposed to turn your phone off before the presentation. If this demo didn't work, it's because they told me to turn my phone off.
So I have a bunch of menu items on my phone like this that correspond to those various scripts that I've loaded in to Sol and Clicker. Oh, Sal's taking a picture. Hi, Sal. You get that? Does one of those scripts say, "Hi, Mom"? I got to go. I got to plane at 3:00. Got to go. Let's take a picture.
So... I have a bunch of different scripts on here where I can do things like click a button on my phone that will cause all the machines to display their IP address, for instance. Or, actually, let me put up the big window so those of you in the back who don't really believe that anything's happening here can see what's happening. Here's the nine computers. Show me uptime. That's a Unix command. Uptime.
Show me the uptime of all these computers. I'm running a Unix command and displaying the result. Let's see. How much disk space is available? If you run the DF command and, you know, grep for this and awk for that and pick out the second line, you can get something like this. Oh, they've all got 56 or 57 gigabytes free.
If you get really fancy here, let me see. Somebody asked me for what launch D items are running. So you can tell which things are running what services. Oh, there's all the launch D items on all the computers. I don't think I'm going to use that one. But I like this one here.
It turns out there is a particular Apple support web page that you can go to and type in the serial number of your computer. Maybe you've seen this. It's apple.com slash support. And in there you can type the serial number of your computer and it will come back with some warranty information about your computer.
Well, how about I have all those nine computers go to that page and type in the serial number and get the result? Let's see what happens. This one takes a moment because each of them is now doing a separate fetch to this support site at Apple. And they're going to come back, I hope, and tell me the warranty status on all these different machines.
That was fun writing that one. Boy, picking cookies apart and scraping the output of the script. So I think as a management tool, this is actually not a bad idea. You've got a large lab. You want to walk around and make the machines do something by clicking the actual buttons in here. I think you might actually find that quite entertaining. I find it quite entertaining. Let's have all the machines say their host name. Let's see. We're doing audio on the iMacs right now. Here comes some audio on the iMacs. Everybody say your host name.
[Transcript missing]
So you can do, I'm taking a big chance here, but you can do other stuff on here as well. I've got some other scripts that do things like put all the machines to sleep. Oh, it's asking for confirmation. Put them all to sleep. Please. And wake them back up.
Now, another thing you can do, I'm not going to show it here, another thing you can do with Sol and Clicker and these other Bluetooth attachment things is have a script executed when this thing loses contact with my laptop over here. Like if I walk out of the room with my phone in my pocket, I can have all the screens lock.
Wouldn't that be cool? Now you've got a little talisman device that locks the entire lab every time you go to the bathroom. All right, maybe not. Might not be the best. So I would encourage people to have fun with these scripts here. There really are a lot of neat things you can do by tying all these different ideas together. And I think for a lot of us, once you get one script working, the rest of them fall out pretty naturally.
Okay, I want--boy, Tony, we're actually going to have time for Q&A because this is going so swimmingly. I haven't had to reboot anything yet. I had some good patter ready for if I had to reboot a computer, but look how well everything's working. I want to try one more thing here. Like many of you, like many of you I'm sure, hands up if you run a marching band in your spare time.
All right, all you people listening to the stream on the QuickTime stream, I wish you could see all the hands that were going up. It's phenomenal. Half the crowd here are apparently marching band leaders. I'm a marching band leader. I run the band for the Toronto Argonauts, and we're working on a song.
We're working on a little GarageBand song here. GarageBand, scriptable. Oh, boy. I got GarageBand. I got Remote Desktop. What can I do? And I've got a Cocoa application. This is an Apple Script Studio application that's going to execute various workflows and shell scripts and Apple scripts in response to clicking on these various buttons.
Well, first thing I'd like to do is I would like to launch GarageBand on all nine of these computers. Here it goes. Clicking a button, GarageBand starting up here. I would like to run a script that copies the current GarageBand song from this computer to all nine computers.
There it is. It's now copying a GarageBand song to all nine computers. Now they've all got a copy of the Liberty Bell March here. But what I really want, this is the future of music education, I want each of these nine machines to play a different part. will run that script here.
And each of them is deleting all but one part. In fact, if you were to look at this one, All it's got left is the trombone part. Here's the trombone sheet music down here. If I were to look at this one over here, Piccolo, this one's got the Piccolo music going by.
In fact, maybe I'd like to use a big honking text just to remind me of who's playing what part. This is the point at which you would have-- This is the point at which-- wait, wait, wait. There's one more button I know you want me to click. This is the point where in my dreams, in my dreams of this session, I had nine musicians were going to come out and stand here, each one of them in front of a different machine and play what they saw. But in lieu of that, Let's just see what happens if we send an Apple script to tell all the machines to rewind to the beginning of the song and play.
One of these machines is only displaying the bell part. Which one is that? Oh, that was a bad idea. This one, display box. Which one of you guys is the bells? There's the bells right there. I'm going to keep an eye on the bells. Oh, nothing happening in the bells part.
Somewhere later, I think there's a bell. Or is it much later in the song? Oh, here comes the bells. We'll wait about a minute here. Perhaps I won't let this play all the way through. Oh, okay. Oh, you want to hear the bell part when it comes in? All right. Thank you. Oh, don't worry, there's a repeat. There's a repeat. The bells are coming.
I think we're ahead of schedule here. Maybe we should look at the trombone part, that might be more interesting. It's got, oh, there it is. There it is, marching along here. Coming up to a bell, get ready. Get your bells up. You all brought a cowbell, right? You all got the note, right? Here it comes, get ready.
I would like to thank the sound guys from the crew for being patient with me and my ridiculous demand that we have audio from nine iMacs for a remote desktop session. Okay, back to you, Tony. Let's play a different song at the end, maybe. So a quick summary.
Apple Remote Desktop's a powerful system administration tool, but you can set it up to be used by folks who are not system administrators. You can integrate it with Apple Script or Automator to expand on its feature sets, do things that it's not able to do out of the box. And you can set it up so that folks who are not system administrators, maybe teachers, maybe even students, can take advantage of its features.