Mac::Glue with Remote Computers
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:
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.
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 FinderThat'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.
$finder = new Mac::Glue 'Finder';
# method for remote Finder
$finder = new Mac::Glue 'Finder', eppc => Finder => 'mac.example.com';
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.
Leave a comment