Hi,
I can´t figure out what to write to get the correct status on my switchBinary CodeDevice.
I have a shellscript turntv.sh with different inputs turns my tv on or off. I use it in Code Device like system("/opt/scripts/turntv.sh on").
The problem is that the device always shows it as off. If i run the script in shell it will echo on or off. I also have a status parameter that returns on or off but the device always shows off.
Can someone push me in the right direction here?
Status on CodeDevice
Re: Status on CodeDevice
what you echo inside the script will be printed to stdout, but is not the result value of the 'system' call.
you can use the exit code inside the script, e.g call 'exit 0' for 'on' and 'exit 1' for 'off' and let the CodeDevice do the rest:
system('/path/to/script')[0]==0 ? 'on' : 'off'
( I am new to JavaScript, so don't ask me why this system call returns an array )
you can use the exit code inside the script, e.g call 'exit 0' for 'on' and 'exit 1' for 'off' and let the CodeDevice do the rest:
system('/path/to/script')[0]==0 ? 'on' : 'off'
( I am new to JavaScript, so don't ask me why this system call returns an array )
Re: Status on CodeDevice
just tested the system call using the second array element, which seems to contain the Output of the script:
in this case you should avoid printing the newline at the end, like:
Code: Select all
system('/path/to/script')[1]
Code: Select all
echo -n on
Re: Status on CodeDevice
Adding [0]==0 ? 'on' : 'off' after calling the script did the trick! Big thank you Guenter!