Execute external shell script

Discussions about Z-Way software and Z-Wave technology in general
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Execute external shell script

Post by pz1 »

Did you make your script executable? If not, do the following on the RaspberryPi console

Code: Select all

cd /opt/z-way-server/automation/storage
sudo chmod +x sendSms.sh
fez
Posts: 147
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez »

I did. I've seen that in the existing posts already.
But thanks for the hint.
fez
Posts: 147
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez »

I am calling a perl script from the shell script. Does that make a difference?
fez
Posts: 147
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez »

I want to get this working, so here are some more information, in case someone could have a look:
This is the content of .syscommands

Code: Select all

/opt/z-way-server/automation/storage/sendSms.sh
I've checked the shell permissions also

Code: Select all

-rwxr-xr-x  1 root root      72 Sep 12 22:23 sendSms.sh
I simplified the shell script to write the date to a file. As before I can execute it on the cmd line, but nothing when the scene is executed. I printed some debug info to follow the execution.

Any idea what could be wrong? What could I check?
Thanks!
fez
Posts: 147
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez »

I didn't get the shell script call working, because I fount and even better solution (for me at least):

Code: Select all

system("perl /opt/z-way-server/automation/userModules/myModule/perlscript" + args);
It looks like the system function accepts any shell command. I discovered accidentally a "system(reboot);" in the existing automation scripts.
Since I had a simple (single line) call I find this even better, because I don't have to bother with .syscommands and is upgrade proof.

Could you Z-Way developers please improve the documentation/manual.

I hope this will help someone.
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Execute external shell script

Post by PoltoS »

system can indeed accept any command provided it starts with something in .syscommands. You found something different?
fez
Posts: 147
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez »

Yes.
I have currently nothing is .syscommands
Still my call works just fine.
I find this comforting, but from security point of view it isn't ideal.

What do you mean by "something"?
Would there be exceptions to this rule like the "reboot"?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Execute external shell script

Post by PoltoS »

There should be no exception. What is your version and OS?
fez
Posts: 147
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez »

jessie 8
z-way 2.2.3
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Execute external shell script

Post by PoltoS »

Please send me your .syscommands from automation folder. The dont see same problems
Post Reply