Mac::Glue with Remote Computers

pudge on 2003-10-31T17:44:42

I never got around to figuring out how to do remote Apple events with Mac OS X. All I knew is that the old method from Mac OS of filling in a complex data structure didn't work.

It worked great on Mac OS, but wouldn't work on Mac OS X. So tonight I decided to figure it out, and I did. Instead of packing the data structure, I just construct a URL. That's all. Something like eppc://pudge@mac.example.com/Finder. And Mac::Glue makes it even simpler:

# normal way, for local Finder $finder = new Mac::Glue 'Finder';

# method for remote Finder $finder = new Mac::Glue 'Finder', eppc => Finder => 'mac.example.com';


That's it. Then use $finder as though it were local. Of course, there is the issue of security. You can pass the username and password to the constructor, or just pass the username and get a dialog box asking for the password. If neither is included, you'll get a dialog box, too. Either way, click "Add to Keychain?" and you never have to see the dialog box again, for that username/hostname combination.

There's also a place in the URL for specifying UID or PID, in those cases where more than one app of that name is running. I tested this and it didn't work, it just chose one and sent the event to that app every time, no matter what. Hm.

Regardless, it's working. Send events to your other Macs. Astound your friends. Requires today's newly updated Mac::Carbon, Mac::AppleEvents::Simple, and Mac::Glue.