Apple Remote Desktop Help
Index

# Executing AppleScripts with Remote Desktop

AppleScripts can be executed on client computers in two ways. They can be saved and executed as an application, or sent at once using the command line.

To learn more about AppleScript, see AppleScript Help in Help Viewer or go to:

www.apple.com/applescript/.

## To send and execute an AppleScript:

1. Save the AppleScript as an application.
2. Open Remote Desktop.
3. Select a computer list in the Remote Desktop window.
4. Select one or more computers in the selected computer list.
5. Use the Copy Items command with the Open Items option selected in the Copy Items dialog.

   See Copy Options for more information.

## To execute an AppleScript using the Send UNIX Command:

This method uses the osascript command. See the osascript man page for more information.

1. Select a computer list in the Remote Desktop window.
2. Select one or more computers in the selected computer list.
3. Choose Manage > Send UNIX Command.
4. Type or paste the AppleScript in the UNIX Command window, like this:
   osascript -e 'First line of script' -e 'Next line of script' [ -e ... ]

   Alternatively, you could use a UNIX "read standard input" redirection which looks like:

   osascript <<EndOfMyScript
   ...insert script here...
   EndOfMyScript

   For example, a simple script to create a folder and set its label would be entered as:

   osascript <<EndOfMyScript
   tell the application "Finder"
   make new folder
   set the name of the result to "New Folder"
   set the label index of folder "New Folder" to 2
   end tell
   EndOfMyScript
5. Click Send.

   The client computer executes the script.