Hi,
I’m trying to find out how to use a pipe with the new exec binding. I want the output of this command:
sensors | grep 'CPU Temperature' | awk '{print $3}' | sed -e 's/\+//' | sed -e 's/°C//'
So I tried this:
Thing exec:command:Temperatura_CPU [ command="/bin/sh -c sensors | grep 'CPU Temperature' | awk '{print $3}' | sed -e 's/\+//' | sed -e 's/°C//'", interval=60, autorun=true ]
But I get this error:
2017-12-26 13:42:06.100 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'casa.things' has errors, therefore ignoring it: [53,46]: mismatched character '+' expecting set null
[53,124]: no viable alternative at input '<EOF>'
Then I tried this:
Thing exec:command:Temperatura_CPU [ command="/bin/sh -c sensors | grep 'CPU Temperature'", interval=60, autorun=true ]
But I’m getting the full output from sensors, ignoring the rest of the command.
If I escape the pipe:
Thing exec:command:Temperatura_CPU [ command="/bin/sh -c sensors \| grep 'CPU Temperature'", interval=60, autorun=true ]
I get this error:
2017-12-26 13:45:50.822 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'casa.things' has errors, therefore ignoring it: [53,69]: Number expected.
[53,46]: mismatched character '|' expecting set null
[53,74]: mismatched input ''CPU Temperature'' expecting ']'
[53,91]: mismatched character '<EOF>' expecting '"'
So, is there a way to use pipes with the new exec binding?
Thanks.