I'm trying to execute an external script on my connected raspberry pi using os.system as you proposed in the recipes:
Execute external command
You can run external commands and scripts from Z-Way. This can be used to control some external software/hardware, send E-Mails and SMS or even make SIP calls via Asterisk!
To run command append script to a scene and add the following into the script
os.system("my_favorite_program_to_play_music")
In my scene, i added:
os.system("sh /home/pi/test.sh")
(The script is working fine if executed locally on the RaspPi)
When the scene is activated, nothing happens on the RaspPi.
Can you help?
Execute external shell script
Note that the script
Note that the script execution is done on the Z-Way side, not on Z-Connector. Hence, it is executed on our server in chroot environment, where there are no sh and bash. Of course this does not work.
The trick was for those using Z-Way as local server. We hope to release Z-Box soon, where this will work perfectly.
The only trick we can propose you is to use HTTP requests to access your Raspberry box via public IP.
The trick was for those using Z-Way as local server. We hope to release Z-Box soon, where this will work perfectly.
The only trick we can propose you is to use HTTP requests to access your Raspberry box via public IP.
Re: Execute external shell script
I have same kind of problem.
I created "sendMail" script to /opt/z-way-server/automation folder.
Then I created toggleButton - CodeDevice and "Code for action on" is set to os.system(sendMail)
Now I tried to push toggleButton from the Widget view but nothing happens and email never sent.
I have verified that script works from razberry command line.
So what I'am doing wrong?
I created "sendMail" script to /opt/z-way-server/automation folder.
Then I created toggleButton - CodeDevice and "Code for action on" is set to os.system(sendMail)
Now I tried to push toggleButton from the Widget view but nothing happens and email never sent.
I have verified that script works from razberry command line.
So what I'am doing wrong?
Re: Execute external shell script
Quick update:
I also tried os.system(/opt/z-way-server/automation), system(/opt/z-way-server/automation) and added /opt/z-way-server/automation to .syscommands file
I also tried os.system(/opt/z-way-server/automation), system(/opt/z-way-server/automation) and added /opt/z-way-server/automation to .syscommands file
Re: Execute external shell script
You should add /opt/z-way-server/automation/yourscriptname.sh to .syscommands.
Even better to save the script in folder storage, so it will survive system upgrades.
Unfortunately after upgrades you have to restore your .syscommands file
Even better to save the script in folder storage, so it will survive system upgrades.
Unfortunately after upgrades you have to restore your .syscommands file
Re: Execute external shell script
Thanks for quick reply.
I moved sendEmail script to storage folder, renamed to sendEmail.sh and also updated .syscommands file.
Still having problems.
Server log file shows:
[2015-04-15 17:31:07.469] [core] --- Code_Device_toggleButton_16 performCommand processing: {"0":"on","1":{}}
[2015-04-15 17:31:07.482] [core] Notification: error (module): Error during perform command execution: SyntaxError: Invalid flags supplied to RegExp constructor 'sendEmail'
[2015-04-15 17:31:07.501] [core] SyntaxError: Invalid flags supplied to RegExp constructor 'sendEmail'
at new RegExp (native)
at CodeDevice.eval (eval at <anonymous> (automation/modules/CodeDevice/index.js:133:14), <anonymous>:1:1)
I moved sendEmail script to storage folder, renamed to sendEmail.sh and also updated .syscommands file.
Still having problems.
Server log file shows:
[2015-04-15 17:31:07.469] [core] --- Code_Device_toggleButton_16 performCommand processing: {"0":"on","1":{}}
[2015-04-15 17:31:07.482] [core] Notification: error (module): Error during perform command execution: SyntaxError: Invalid flags supplied to RegExp constructor 'sendEmail'
[2015-04-15 17:31:07.501] [core] SyntaxError: Invalid flags supplied to RegExp constructor 'sendEmail'
at new RegExp (native)
at CodeDevice.eval (eval at <anonymous> (automation/modules/CodeDevice/index.js:133:14), <anonymous>:1:1)
Re: Execute external shell script
kimeh, wrap the command name in quotes
Razberry B+ 2.0.1-rc25 on ZW500 + 15 devices / Razberry B 2.0.1-rc25 on ZW300 for test
Re: Execute external shell script
thanks, Now it works!
Re: Execute external shell script
Hi,
I am trying to do the same as above with a shell script but it doesn't work for me.
I call the script from my module like this:
I added the full path to the .syscommands (without the quotes).
When I execute the scene I get no errors, but still I fail to see the effect (no SMS).
I tested successfully the script from the command line.
Any idea what I have missed?
thanks.
I am trying to do the same as above with a shell script but it doesn't work for me.
I call the script from my module like this:
Code: Select all
system("/opt/z-way-server/automation/storage/sendSms.sh");
When I execute the scene I get no errors, but still I fail to see the effect (no SMS).
I tested successfully the script from the command line.
Any idea what I have missed?
thanks.