2020-03-13 Can I Issue an instruction to XTension with a shell script rathe than with a applescript ?
James Sentman
james at sentman.com
Sat Mar 14 10:20:35 EDT 2020
Of course :)
There is always more than one way to do something. We just need another way to get an event into XTension. As a first try I would suggest the HTTP/JSON server. You can create an instance of that interface in XTension and add a security “token” to the list at the bottom of the setup window. Then create a new non-dimmable Unit and assign it to the new Json server instance. Give it an address as if it was a real unit something like “BACKUPDONE” but whatever you like is fine, easier if it doesn’t have spaces or special characters or accents or anything as it will be part of the URL in the next step.
Put your script for turning off the drives into the ON script of that unit.
Then in the post flight script in CCC you can do something like this. This is assuming you setup the JSNO server for port 8080, but you can use any port just change it in the curl link below:
#/bin/sh
curl “http://localhost:8080/yourTokenFromAbove/BACKUPDONE/on”
You might have to use a fully qualified path for curl now that I think about it. I’m not sure what the path variables are available to the script when it’s running as root so instead of just directly calling curl you should probably use the full path. On my mac here that appears to be the rather odd “/opt/local/bin/curl” calling that directly does work on my machine. If it’s different on other OS versions or something else doesn’t work you can double check it by doing a “which curl” from the terminal and it will show you what it is on your machine for sure.
That will make a request to that link and if the Address matches it will send an On to the unit you created with that same address and from that Unit’s On Script you can now run any applescripts or turn on or off any other units that you need to. The unit wont ever turn off and that doesn’t matter. You could always add a “turnoff (thisUnit) in 2” to the bottom of it’s On script, but that is unnecessary.
Let me know if that works or if we need to figure out another way to do it. I could do a whole shell script helper app for access to XTension, but that would be a larger project and therefore not going to appear as soon as you could get this working.
> On Mar 13, 2020, at 6:09 PM, Michel Angelo <michel_angelo at me.com> wrote:
>
> Hello James, Hi Philippe.
>
> I hope your health prospects are fine on your side of the Atlantic.
>
> I am still struggling with my backup with CCC operations. The sequence is as follows:
>
> theM acBookPro install of XTension running on the MavcbookPro can (1) power up an external drive and (2), by an applescript commanding a shell script, instruct XTension to start backup operations.
>
> Then, the MacBookPro install of CCC, running on the MacBokPro, clones the MacbookPro internal drive and its attached external drive to partitions of two external drives (one for weekdays and one for Sunday) attached to an iMac (this is done by a network connection).
>
> These backup drives can be noisy and consume electrical power, so I shut them down when the backup task is complete and the CCC has ejected all the backup partitions.
>
> Today, I do that with an independent timer, which timer ignores whether or not the backup tasks are completed.
>
> Xtension, controlling a Vera, can easily power down the backup drives. I want XTension to replace my timer and receive from CCC the information that the last backup task is completed. But CCC does not do applescript. This is what Mike Bombich tells me about it:
>
> "AppleScripts aren't supported for use with CCC's pre and postflight scripts. CCC's scripts run as the root user, and that poses challenges to AppleScript. In particular, the "tell application ..." part is going to fail – CCC runs "headless", and the invoked AppleScript will be unable to talk to the WindowServer – it will be unable to launch that application."
>
> I understand XTension reliance on Applescript is bound to fail here. Can XTension receive instructions directly from a shell ()"postflight") script, which CCC can easily issue ?
>
> Thanks for any help in this.
>
> Copy of the shell script using an applescript which cannot work=
>
> #!/bin/sh
>
> osascript /Library/Application\ Support/com.bombich.ccc/Scripts/sPowerDownD2.scpt
>
> while the called upon applescript (sPowerDownD2.scpt) simply states:
>
> tell application "XTension"
> execute script "Sauvegardes" handler "hPowerDownD2"
> end tell
>
> Is there any hope ?
Thanks,
James
James Sentman http://www.PlanetaryGear.org http://MacHomeAutomation.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20200314/823c058e/attachment.html>
More information about the XTensionList
mailing list