Trigger AppleScript Execution from Linux Using HTTP / SOAP / REST?


I have a X10/Insteon controller (ISY99i) from Universial-Devices - This device, which under the hood is running linux, with their Network Module added, can be programmed to both respond to REST calls ( and issue calls using HTTP - see

I know I can issue a REST call from inside an AppleScript to the ISY99 to trigger the ISY99 to trigger an X10 or Insteon Command to turn on a light (or any other X10/Insteon device) ( and

But I also need to do the reverse. i.e. someone presses an X10/Insteon switch and the ISY99 then sends a HTTP / SOAP / REST call to a Mac and have it execute a specific AppleScript. I know the ISY99 can issue commands - see

I also know I can remotely exectue AppleScripts from other Macs from inside an AppleScript (using

tell application "theApplication" of machine "eppc://username:password@host" ... end tell

But I’ve not yet figured out how I can trigger an AppleScript from a SOAP / REST call from the ISY99 (or anywhere else).

I’m guessing I have to be running some sort of deamon / service on the Mac which listens for the HTTP / SOAP / REST call and then calls the AppleScript using something like the command osascript

Or is there a simpler way?

Model: MacBook
AppleScript: 2.0.1
Browser: Safari
Operating System: Mac OS X (10.5)

I think the above is saying you can send emails. If that’s right then you have something that could help there. On the mac, can be set up to run an applescript when an email arrives. That could be your ticket. A quick search of the forums should turn up some example to show you how to set up


I have no Idea if this could work (or is possible, except for the launch item, never dedicated a socket to a port, but that must be possible!

How about having a Launchd process listening on a socket, and execute an osascript, when the port you have set up for the socket gets pinged? (changes state), that should trigger the dedicated Launchd process/item, which then runs an AppleScript through osascript for you? Of course you have to the the “ping thing” from your end.

Hopes this helps and best regards.

Hanks Solution is bullet proof!

Google for Juliossoft and Mail Commander.

Best Regards


The X10/Insteon controller canmpt send a mail message - it doesn’t talk SMTP - only HTTP.

This is what I was thinking…perhaps using NetCat (or nc) (which I believe handles all the port and socket stuff) but I was rather hoping someone had either a more elegant solution or had already written some scripts to do this… :smiley:

Since it can’t send emails here’s another thought. Why not use the built-in apache web server on the mac? You can enable php on the web server, and run your applescripts from php commands. A quick google search turned up this page which shows how to setup apache and a web page to control itunes. You can adjust it for your needs. And since this would all be taking place within your local lan (I’m assuming) then the security issues are under control.


Hank is absolutely right about the security. A random “sweeper” might trigger an applescript for you by a ping.
I didn’t give that much thought yesterday when I posted the idea. I have enhanced the idea on the Mac side, to
involve sever ports and launchd items which all call osascripts, which in turn calls a stay open applet.
The Applet would then decide what script would be executed, and if it would be executed. After having received a certain pattern of triggers within some “coarse” timeframe.

This isn’t a totally secure solution, but if you only listens for pings on the ports, and isn’t having somebody sending you the ping of death, you should be all right. The stay open applet, could also reinstall any “dead” launchd items on demand, having a dual purpose as a care taker of the system as well.

By the way, I you have linux, you have java, and it should take you about an hour to “roll your own” email sender in java. Then you could talk SMTP. I guess that you have the Linux tools available with the HTTP, SOAP and REST calls.

Hanks solution might be both better and safer. Both regarding Mail and to use the Apache and AS via PHP.

Best Regards


(nearly) perfect. I can definitely use this method.

I was just kind of hoping that the applescript:// URI might be available remotely - i.e. put applescript:///<applescript_name> into the address bar of any browser on the calling machine - but I think I’m begining to understand the applescript:// URI only works locally (not sure what the point of it is).

Completely understand the concern. In my case I am behind a firewall. But using the php method described at the URL hank provided I could easily use https and also turn on domain security (I think I remember that’s what its called) in appache to prompt for a user name and password on the php control page.

Like your approach though - nice and clean.

the ISY99 (X10/insteon controller) is running embedded linux - so I have very limited access to the command line - and hence installing java would be challenge…but I like your idea!

Thanks for all the help guys…


The point of this is to open code from a html page into a browser. You should see some usage of it around here. :slight_smile:

Best Regards


I get that its useful to be able to execute an applescript from a local browser (or html page)… what I don’t understand is why it doesn’t work remotely.

Clearly I don’t understand the mechanics… if applescript://localhost/<applescript_name> works there must be something very like the php to applescript interface mentioned in the URL Hank provided already available (I know applescript is registered as a protocol helper). In this case I assume the local webserver takes the requests and then sends the URL on to the “AppleScript Engine” using the AppleScript protocol helper.

What I don’t understand is if this works locally why can’t I just replace localhost with an IP address and make the same call from a remote machine?

Any insights?


You could use the eppc protocol in order to execute remote apple events, the catch is that this goes through applevents, which I think means that you had to use AppleScript to execute it from your client machine in the first place.

Have you considered ard?

Best Regards


Yep…you are right… you need a Mac to send eppc so that won’t work in my case.

Apple Remote Desktop aka vnc? I did a google on ard that’s the only thing that came up - but not sure how that would help so suspect I’ve got the wrong ard! :confused:

Still interested in understanding why applescript:// won’t work from a remote machine. The more I think about it the more I don’t understand how it could work locally applescript://localhost/ and applescript://IP address/ won’t work. Any thoughts?

Hello. yes.

I guess you had to build your own server with support for it, or edit the MIME configuration. :slight_smile: It would be intersting to see if it actually is represented as a protocol on the Apache.

I think it is a protocol that is defined as client side only, like javascript without Ajax, sorry but you know what I mean.

If you knew enough about MIME and had the guts to set up your own protocol and all that. I know you can do it with a tomcat server and java servlets. But it isn’t something done overnight. And I’m not sure if you could do it if you circumvent the browser.

AppleScript and Mac Os X makes that very easy in the client side: You had to use something like this on the client side to match proposal the server side above: webpagehelper
(You could use the above example to make applescripts execute from your browser instead of showing up in the script editor. -It also teaches you how to make new client side protocols via applescript.

I’m sure all this can be done. But I think my initial solution with some ports, sockets and launchd would be easier. Hanks solution is the best overall solution I think.

I thought it was some open source scriptable vnc around. You would have to use the same in both ends. With Mac Os X you might use X Windows as a work around. So you should have access to a great deal of software just have to make sure it is bug free and compiles.

:smiley: Mac Os X is really an amazing platform!

Don’t really know if I gave you any answers, but I tried as I ranted along.

Best Regards