2020-03-13 Can I Issue an instruction to XTension with a shell script rathe than with a applescript ?
BobsXTension at comcast.net
BobsXTension at comcast.net
Sun Apr 5 15:03:06 EDT 2020
Michel
Color me lazy, but I just have XTension blindly turn off the back up
disk power after 5 hours.
No problems, yet!
Bob Ober
On 4/5/20 8:18 AM, Michel Angelo wrote:
> Hello.
>
> Back there on march 13, I had enquired about powering up and down my
> backup drive in conjunction with automated CCC backups. I had found
> the way for Xtension to power-up the drive and initiate the CCC backup
> chain but was failing on the return trail: namely from CCC sting
> « Backup done to XTension for XTension to power-off the drive.
>
> Thank you for your solution, which seems rather a tough sell to me.
> However, given that I have just now succeeded setting up a
> « Locative » geofencing trigger in my iPhone and succeeded to get
> XTension to receive and understand the IN and OUT messages (it took me
> a month), I will try it.
>
> On his side, Mike Bombich had suggested a direct shell script route
> with sudo in it, even more complex to me and which I could not get to
> work (probably a permissions issue which an expert would have solved
> easily). My workaround was to instruct CCC to issue a post-backup
> email to me with a special magic sentence in the header and to get the
> application « Mail », through a mail-action detecting my magic
> sentence, to run the applescript:
>
> tell application "XTension"
> execute script "Sauvegardes" handler "hPowerDownD2"
> end tell
>
> It ends up in a handler of my master backup script in XTension, which
> is as follows:
>
> on hManPowerDown(theDrive)
> if theDrive = "D2" then set theSwitch to "ClonageD2Switch"
> set valueSwitch to value of theSwitch
> if (valueSwitch) = 1 then
> turnoff theSwitch
> else
> write log "The switch was already open"
> end if
> end hManPowerDown
>
> It may not seem to be very robust as mail actions may be omitted when
> the mac is asleep but, surprise, surprise, it has worked for me so far
> without any surprise.
>
> As an information to listers, the XTension instruction to CCC was
> reasonably easy, even for me. This is also a handler in my Backup main
> script in XTension.
>
> on hTriggerBackup(theSequence, theDrive)
> if ((theSequence = "EachDay") and (theDrive = "D2")) then
> set thePath to the quoted form of "/Applications/Carbon Copy
> Cloner.app/Contents/MacOS/ccc"
> set theBackUp to the quoted form of "11ClonageD2DeMBP"
> do shell script thePath & " -s" & theBackUp
> else if ((theSequence = "Sat1") and (theDrive = "D2")) then
> set thePath to the quoted form of "/Applications/Carbon Copy
> Cloner.app/Contents/MacOS/ccc"
> set theBackUp to the quoted form of "21ClonageD2S1DeMBP1"
> do shell script thePath & " -s" & theBackUp
> else if ((theSequence = "SatLast") and (theDrive = "D2")) then
> set thePath to the quoted form of "/Applications/Carbon Copy
> Cloner.app/Contents/MacOS/ccc"
> set theBackUp to the quoted form of "31ClonageD2S5DeSea1"
> do shell script thePath & " -s" & theBackUp
> else
> -- Do nothing
> end if
> end hTriggerBackup
>
> Thanks you James. I was planning to ask a question about Locative
> because of my inability to follow the instructions in the wiki.
> Instead, I wonder what to do if my wife refuses (as she currently
> does) to install and get to work 100% of the time Locative in her
> iPhone ; and the same question goes for visitors in my home in
> wintertime when heating is ON. Can I give them little tracking devices
> to keep in their pocket or car, doing the same job as locative does on
> an iPhone ?
>
> Thank-you, James.
>
> —
> Michel Angelo
> <michel_angelo at me.com <mailto:michel_angelo at me.com>> macOS 10.13.6
>
> On 14 mars 2020 at 15:20, James Sentman <james at sentman.com
> <mailto:james at sentman.com>> has written :
>
>> 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.
>
>
> —
> Michel Angelo
> <michel_angelo at me.com <mailto:michel_angelo at me.com>> macOS 10.13.6
>
>
>
>
> _______________________________________________
> XTensionList mailing list
> XTensionList at machomeautomation.com
> http://mail.machomeautomation.com/mailman/listinfo/xtensionlist
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20200405/cd09e62a/attachment.html>
More information about the XTensionList
mailing list