Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARD3 and AppleScript



On 3-May-06, at 9:57 AM, Allan McCoy wrote:

I'm cross posting this inquiry to both the ARD list and the AppleScript because it involves questions about scripting ARD...

And I'm replying only to the ARD list.


When I "Send Unix command" and get back result text in a window, is there any way to grab that text in AppleScript? I downloaded a trial of Script Debugger which is very nice but so far isn't showing me any way to access what I want.


When you create a send unix command task in applescript, you get a somewhat complicated record back that includes one entry for each machine on the original list, containing a machine ID, IP address, success/failure status - and a string called "results" that's the output of the command.

So if you do this - let's create a script that runs the "date" command on some remote machine

tell application "Remote Desktop"
set m to computer "threeforty"
set newTask to make new send unix command task with properties {name:"get the date", script:"date"}

set taskResults to execute newTask on m
end tell


you get back this - a record with a key called "computerStatuses", which is a list of records for each computer you executed the command on.

{|computerStatuses|:{{|id|:"71D2AD8E-C79F-47FD-8657-61FA472A8FDC", address:"192.168.1.2", results:"“Wed May 3 12:55:38 EDT 2006”"}}, status:"Succeeded on all"}

So you could do

display dialog "The remote date is: " & |results| of item 1 of | computerStatuses| of taskResults

A couple of notes. The text that you get back has actual double quotes in it so you might want to remove them via something like


set remoteResult to text 2 through -2 of |results| of item 1 of | computerStatuses| of taskResults



Also if the remote task produced no output, the string you get back is "Succeeded" - without the double quotes.


Also also I believe you can only get back the last line of the output this way even if multiple lines were produced but for many simple commands this will be fine.

Hope this helps,
steve


_______________________________________________ Do not post admin requests to the list. They will be ignored. Remote-desktop mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/remote-desktop/email@hidden

This email sent to email@hidden
References: 
 >ARD3 and AppleScript (From: "Allan McCoy" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.