views:

64

answers:

2

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 corresponding AppleScript command.

Thanks!

+1  A: 

Take a look at SBApplication, which supports the eppc: remote application protocol for sending remote Apple events.

Alex Reynolds
iPhones don't support AppleScript, Scripting Bridge, or any other Apple event-related technologies, so that won't work. I suppose if you wanted to be really clever, you could hack up a distributed version of objc-appscript by replacing the platform-specific portions (NSAppleEventDescriptor, AESendMessage) with your own serialization and transport mechanisms, but I think if you're going to invest that amount of effort you'd be better building a truly portable solution using something like SOAP.
has
+1  A: 

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.

has
what I'm trying to do is make an app that can control certain applications on the target machine to do things like set your skype/adium status, control itunes, and some other stuff
Mark Szymanski