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 » 12 Sep 2016 11:27

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: 105
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez » 12 Sep 2016 11:36

I did. I've seen that in the existing posts already.
But thanks for the hint.

fez
Posts: 105
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez » 12 Sep 2016 12:51

I am calling a perl script from the shell script. Does that make a difference?

fez
Posts: 105
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez » 12 Sep 2016 23:36

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: 105
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez » 13 Sep 2016 02:36

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: 5103
Joined: 26 Jan 2011 19:36

Re: Execute external shell script

Post by PoltoS » 14 Sep 2016 00:10

system can indeed accept any command provided it starts with something in .syscommands. You found something different?

fez
Posts: 105
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez » 14 Sep 2016 08:14

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: 5103
Joined: 26 Jan 2011 19:36

Re: Execute external shell script

Post by PoltoS » 17 Sep 2016 01:48

There should be no exception. What is your version and OS?

fez
Posts: 105
Joined: 20 Jul 2015 23:03

Re: Execute external shell script

Post by fez » 17 Sep 2016 08:28

jessie 8
z-way 2.2.3

User avatar
PoltoS
Posts: 5103
Joined: 26 Jan 2011 19:36

Re: Execute external shell script

Post by PoltoS » 17 Sep 2016 09:30

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

Post Reply