|The webcast in May featured Steve Hayman introducing Automator actions for Apple Remote Desktop 3. They are provided here for your enjoyment!|
May 17 2006
© Copyright 2006 Apple Computer, Inc. All rights reserved.
IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. (“Apple”) in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in this original Apple software (the “Apple Software”), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
Here are some example Automator actions that I showed during the MacEnterprise.org webcast. Source for the actions is included in the "Projects" folder.
Please consider these all works-in-progress. I hope they give you some interesting ideas.
Two simple command line tools are included in Binaries which you may find useful with ARD's Send UNIX Command:
• A tool to turn the System Identifier light on an Xserve on and off. Use IdentifierLight --help to see the available options, including flashing the light at different speeds or even displaying a message in Morse code.
• A tool to display a text message in large letters, visible from across the room,. Use BigHonkingText --help for options. Run this command as root and it will even display the message on top of the login window. Some examples
Displays the message "Hello" for 3 seconds
BigHonkingText -p 30 Hello
Displays "Hello" for 30 seconds, or until someone clicks on the window
BigHonkingText -d -p 30 Hello
As above, except return immediately. Don't wait for the user to click.
BigHonkingText -w 500 -h 300 Hello There
Display the message in a 300x500 window. You can also specify percentages. The default is "-w 90% -h 20%"
Produce an authentic Canada Goose honk to go along with the message.
Of course you can display the output of a command too. You might find
to be useful in a large lab.
Included are the source and binaries for 5 automator actions all of which are intended to follow one of the ARD "Choose Computers" actions. The actions in the Actions folder can be placed in ~/Library/Automator.
Most of these actions are written in Applescript, and involve constructing a shell script on the fly. The script is then passed to the remote computer(s) via "make new send unix command task", and the result may be extracted. Note that at the moment only the last line of the remote command's output is available to you in this way.
Ask a Question
Uses "display dialog" to display a question and 1 to 3 answers on a group of machines, and tallies the results. Follow this with "Prepare Data for Keynote Chart", and the Keynote "Add Chart to Slide" action, if you want to produce a graph of the result.
You might construct a workflow like this. I would suggest launching Keynote first, and arranging that it i
Remote Desktop > Choose Remote Computer
Remote Desktop > Ask a Question
Click on the "Summary" checkbox to have the action total the results
Keynote > Prepare Data for Keynote Chart
Keynote > Add Chart to Slide
Choose "Chart Type: Pie 3D" and "Chart Group: Column" for a nice result.
Change User Password
Changes the password for a specified user on a bunch of machines. What this is really doing is
dscl . -passwd /Users/username newpassword
on each machine from the previous action. This will work for local user accounts but not, alas, for accounts from network directories. For that we would need to design a new action that also takes an admin username and password, and do something like
dscl datasource -u adminuser -P adminpasswd -passwd /Users/username newpassword
but I have not written that action yet.
This action uses some tricks to arrange not to save the password in the workflow. You might like to choose "Show action when run" if adding this to your own workflow,
Distribute Items to Users
Here is a way to distribute files to the home directories of all users on a remote computer, not just the logged in user. For this to work you will also need the Store Disk Item References andRetrieve Disk Item References actions which are included with Aperture, if you have that, or which can be downloaded from http://www.automator.us.
To use this, build a workflow like so
Get Specified Finder Items
Store Disk Item References
Remote Desktop > Choose Computer List
Retrieve Disk Item References
Distribute Items to Users
In this action you can choose to distribute the passed-in files to all users, or members of a specific group.
How it Works.
This particular action actually creates and runs 3 ARD tasks
1) It creates a folder called "/tmp/distribute" on the remote machine
2) It copies the passed in files to /tmp/distribute
3) It executes a shell script ("distribute.sh") on the remote machine to copy the files out of /tmp/distribute into the specified user folder for each user. The distribute.sh script uses "dscl" to determine the appropriate list of users and home folders.
Execute Per-User UNIX Task
This is like the existing Execute New UNIX Task in that you can give it a shell script to run on the remote computer, except in this one, you can specify some criteria for users, and have the task executed once (via "su") for each matching user.
For instance you might specify a command like
defaults write com.someapp somesetting blah
and use this to run it once for each user whose Home Folder matches /"Volumes/D4/Students"
Note: The "Group list" thing in the UI isn't hooked up yet. I'm working on it.
How It Works:
It's somewhat convoluted in that it builds a shell script on the fly that will match the users you selected, and loop through them executing your script via "su" for each one.
There are two shell scripts, "preamble.sh" and "postamble.sh" included in the action. main.applescript constructs a new shell script on the fly, based on these two scripts, the users you chose, and the command you want to execute, and passes it to the remote machines as a send unix command task. It builds a script by concatenating, in order
- The shell statement
thescript="Contents of your script here"
dsclNode="The dscl node you specified"
This script fragment runs "dscl" to pick up a list of users, and includes the first part of a perl script to loop through users and include/exclude them
- Some perl statements to include and exclude various users from the script.
A loop to go through every user that made it through the perl exclusion statements, and use "su" to execute the commands on their behalf.
It takes this resulting script and passes it to the remote computer as a new send unix command task.
Prepare Data for Keynote Chart
This item just reformats the text coming out of Ask a Question into the right kind of Applescript record so that Keynote's Add Chart action can handle it.
The examples are attached to this article