Send AppleScript to remote computer in Objective-C
How do you use Objective-C (iPhone) to send an AppleScript to a remote computer (on same network) to be executed?
I think something like NSNetService
would be of use here, but I don't know.
EDIT: Ok, to clarify, all I want to do is send a command ID or something and then the Computer associate that with the correspon开发者_如何学运维ding AppleScript command.
Thanks!
Take a look at SBApplication
, which supports the eppc:
remote application protocol for sending remote Apple events.
NSNetService lets you broadcast the availability of your service, though you'd still need to provide your own transport mechanism (e.g. HTTPS) for passing data.
A better question would be: what are you trying to achieve? Personally, I'd be extremely leery of opening up any sort of service that allows external parties to run arbitrary code on the target machine; even allowing outside parties to send Apple events would be a major security issue.
If you're just looking to, say, manipulate iTunes or iPhoto remotely, I would recommend implementing a server-side service that exposes only the functionality your iPhone client actually needs.
Alternatively, if you really want to control AppleScriptable applications directly from your iPhone, I'd suggest ssh-ing into the remote Mac and using osascript to run AppleScripts there. Apart from anything else, this puts the responsibility for security onto the Mac admin and ssh, rather than yourself.
精彩评论