Send AppleScript to remote machine in Objective-C

How do you use Objective-C (iPhone) to send AppleScript to a remote computer (on the same network) that needs to be executed?

I think something like NSNetService

will be helpful here, but I don't know.

EDIT: Okay, to clarify, all I want to do is send a command id or whatever, and then the computer associate that with the appropriate AppleScript command.

Thanks!

+2


a source to share


2 answers


Take a look at SBApplication

which supports remote application protocol eppc:

to send Apple remote events.



+1


a source


NSNetService allows you to broadcast the availability of your service, although you still need to provide your own transport mechanism (like HTTPS) to transfer the data.

The best question is, what are you trying to achieve? Personally, I would be extremely careful about opening any kind of service that allows outside parties to run arbitrary code on the target machine; even allowing outside parties to send events to Apple would be a major security issue.



If you just want to, say, manipulate iTunes or iPhoto remotely, I would recommend implementing a back-end service that only provides the functionality your iPhone client really needs.

Alternatively, if you really want to control AppleScriptable applications directly from your iPhone, I would suggest ssh-ing to a remote Mac and use osascript to run AppleScripts. Among other things, this puts the responsibility for security on the Mac and ssh administrator, not himself.

+1


a source







All Articles