Problem with Javascript Code execution from Z-Way
Posted: 20 May 2016 06:33
I've used the Javascript code execution app in previous versions with much success but am having problems with v2.2.2 running on jessie. I've done some diagnostics by adding code that prints to a file in /tmp to try and troubleshoot. Below is my javascript code, followed by the bash script called with the "system" command.
Javascript code
---
zway.devices[5].instances[0].commandClasses[48].data[1].level.bind(function() {
if (this.value == true)
system('/opt/z-way-server/automation/userModules/movement.bash');
});
---
movement.bash code
---
#!/bin/bash
/usr/bin/mail -s "Security Alert from Brandon-Pi" <cellnumber>@vtext.com < ./movement.message
date > /tmp/tmpfile
---
If I log in as the user "pi" via ssh and execute the "movement.bash" script, everything works like it should. If I run the script as "root", it too works like it should. But if I trigger my motion detector, the script gets executed, the date gets copied to the tmpfile but the mail message doesn't get sent to my cell phone. Because of this, I know the movement.bash script is getting called properly and executed. Right now, I only have the movement.bash name in the .syscommands file. I tried adding /usr/bin/mail but is doesn't make any difference. I'm sure it's a linux issue but I'm hoping I've forgotten something in ZWay so this forum can help. Thanks in advance.
Javascript code
---
zway.devices[5].instances[0].commandClasses[48].data[1].level.bind(function() {
if (this.value == true)
system('/opt/z-way-server/automation/userModules/movement.bash');
});
---
movement.bash code
---
#!/bin/bash
/usr/bin/mail -s "Security Alert from Brandon-Pi" <cellnumber>@vtext.com < ./movement.message
date > /tmp/tmpfile
---
If I log in as the user "pi" via ssh and execute the "movement.bash" script, everything works like it should. If I run the script as "root", it too works like it should. But if I trigger my motion detector, the script gets executed, the date gets copied to the tmpfile but the mail message doesn't get sent to my cell phone. Because of this, I know the movement.bash script is getting called properly and executed. Right now, I only have the movement.bash name in the .syscommands file. I tried adding /usr/bin/mail but is doesn't make any difference. I'm sure it's a linux issue but I'm hoping I've forgotten something in ZWay so this forum can help. Thanks in advance.