Exec Binding, i'm lost

I have a WARN message that continually come up I believe its because of the exec thing I have defined, which I have reduced to its basic’s.
looking at the REST entry for the Thing, I see it does indeed have a REGEX type stated but I never set that, is this an issue in the binding or have I screwed up somewhere?

  {
    "statusInfo": {
      "status": "ONLINE",
      "statusDetail": "NONE"
    },
    "label": "Command",
    "configuration": {
      "transform": "REGEX((.*))",
      "interval": 60,
      "autorun": false,
      "command": "/usr/bin/control_hal.sh",
      "timeout": 15
    },
    "properties": {},
    "UID": "exec:command:exec-hal",
    "thingTypeUID": "exec:command",
    "channels": [
      {
        "linkedItems": [],
        "uid": "exec:command:exec-hal:output",
        "id": "output",
        "channelTypeUID": "exec:output",
        "itemType": "String",
        "kind": "STATE",
        "defaultTags": [],
        "properties": {},
        "configuration": {}
      },
      {
        "linkedItems": [
          "HalControlCMD"
        ],
        "uid": "exec:command:exec-hal:input",
        "id": "input",
        "channelTypeUID": "exec:input",
        "itemType": "String",
        "kind": "STATE",
        "defaultTags": [],
        "properties": {},
        "configuration": {}
      },
      {
        "linkedItems": [],
        "uid": "exec:command:exec-hal:exit",
        "id": "exit",
        "channelTypeUID": "exec:exit",
        "itemType": "Number",
        "kind": "STATE",
        "defaultTags": [],
        "properties": {},
        "configuration": {}
      },
      {
        "linkedItems": [],
        "uid": "exec:command:exec-hal:run",
        "id": "run",
        "channelTypeUID": "exec:run",
        "itemType": "Switch",
        "kind": "STATE",
        "defaultTags": [],
        "properties": {},
        "configuration": {}
      },
      {
        "linkedItems": [],
        "uid": "exec:command:exec-hal:lastexecution",
        "id": "lastexecution",
        "channelTypeUID": "exec:lastexecution",
        "itemType": "DateTime",
        "kind": "STATE",
        "defaultTags": [],
        "properties": {},
        "configuration": {}
      }
    ]
  },

The log shows this:

22:07:51.355 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type REGEX
22:07:51.357 [WARN ] [hab.binding.exec.handler.ExecHandler] - Couldn't transform response because transformationService of type 'REGEX' is unavailable

Any ideas? I don’t like WARN’s in my logs as a rule.

Did you by any chance forget to install Regex Transformations from Paper UI, Add-ons-Transformations-Regex Transformation ?

Thanks, I was not aware that I needed to install it. I have now installed ALL the transformations so hopefully they do not conflict and I have prevented any other future addon needing a transformation I have not installed. If that is the wrong approach please let me know.

Back to my journey understanding the exec binding.

I would like to run a script once and only once when it is triggered.
I have set up the following thing and items, but when triggered the shell script is run every 60 seconds, how do I set this to only occur once and then stop?

//.things
Thing exec:command:exec-hal [ command="/usr/bin/control_hal.sh" ]


//.items
String HalControlCMD "Hal" { channel="exec:command:exec-hal:input", autoupdate="false" }
//
Switch Hal "Hell" (network) ["Switchable"] 

I expose 'Hell to Alexa and she is used to trigger the calling of the script.

So how do I run a script once every time its triggered and then stop?

The other issue I also see is if I add ‘%2$s’ to the end of the shell command I expect that the value I send in this case ON or OFF will be passed to the script as a parameter )I am sure this was working and then stopped) instead I get another error in the log, see below:

14:52:55.862 [ERROR] [hab.binding.exec.handler.ExecHandler] - An exception occurred while formatting the command line with the current time and input values : 'Format specifier '%2$s''

I seem to be having a hard time for what on the surface seems like a simple use case.

Thanks
Paul

Instead of defining the script command in Things, why don’t you use executeCommandLine ("/usr/bin/control_hal.sh@@ON",2*1000) ? So you can use this in a rule to bind it to a dummy switch?

I was not aware of this option, I have tried the two flavours below neither shows signs of actually executing the command. Is this not how I should use it?

rule "hal-control"
when
Item Hal received command
then
if (receivedCommand == OFF) {
	//postUpdate(WOL_Hal,OFF)
	//HalControlCMD.sendCommand(OFF)
	//executeCommandLine ("/usr/bin/control_hal.sh@@ON",2*1000)
	var String results = executeCommandLine("/usr/bin/control_hal.sh@@ON",1000)
	logInfo("wol.rules", "Hal shutdown requested")
	}
if (receivedCommand == ON) {
	//postUpdate(HalControlCMD,ON)
	HalControlCMD.sendCommand(ON)
	logInfo("wol.rules", "Hal Wake-up requested")
	}
end

Thanks

Paul

[EDIT]
It worked great as you said, I put the commands in the OFF section and called the ON; major OPS!!!

Thank you for the help!!

Nice to hear, if you can post your rule in its final form, maybe it can help others you might have a resembling problem.

Here is the working set of stuff.

.items

Switch Hal "Hal" (network) ["Switchable"] 

.rules

rule "hal-control"
when
Item Hal received command
then
if (receivedCommand == OFF) {
	executeCommandLine ("/usr/bin/control_hal.sh@@OFF",2*1000)
	logInfo("wol.rules", "Hal shutdown requested")
	}
if (receivedCommand == ON) {
	executeCommandLine ("/usr/bin/control_hal.sh@@ON",2*1000)
	logInfo("wol.rules", "Hal Wake-up requested")
	}
end

.sitemap

		Text label="WOL" icon="network" {
			Switch item=Hal mappings=[ "ON"="Wake Up", "OFF"="Shutdown"
			}

The BASH script is quie simple
/usr/bin/control_hal.sh

#!/bin/bash
# Control power of Win10 Desktop remotely. Shutdown and wakeup by Paul
# Miller 2017 Revisions: 0.1 - 08/01/2017 Initial Release 0.2 -
# 04/06/2017 Merged shutdown and wakep IFTTT triggered scripts into
#                  one script that receives ON and OFF and acts
#                  accordingly.
logger "***********************************************"
logger "Script $0 has been executed."
logger "Received: $1"
logger "***********************************************"

if [ $1 = "ON" ]; then
        ############################################
        #### send WOL command
        # sudo apt-get install -y etherwake
        wakeonlan 00:00:00:00:00:00
fi

if [ $1 = "OFF" ]; then
        #### send RPC command
        net rpc shutdown -I 192.168.0.65 -C 'Shutting down at remote request' -U USER%PASSWD
fi

/usr/bin/logger "$0 execution completed."
exit 0

I also expose the switch hal so that Alexa can turn on and off the PC too.

Thanks

Paul