Problem with "os.execute" in dzventz

Easy to use, 100% Lua-based event scripting framework.
Post Reply
cdjseb
Posts: 4
Joined: Thursday 18 January 2018 10:42
Target OS: -
Domoticz version:
Contact:

Problem with "os.execute" in dzventz

Post by cdjseb » Thursday 18 January 2018 11:00

Hello.
I'm making a script for rebooting a computer.
When i'm connect to domoticz with SSH, i have a command who is working :

*** ssh user@host -p port sudo reboot *** (user / host / port are different obviously)

but when i include this command in my script, it's not working !

*** os.execute('ssh user@host -p port sudo reboot') ***

Anybody can help me please ?
Many thanks in advance !

User avatar
emme
Posts: 956
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Problem with "os.execute" in dzventz

Post by emme » Thursday 18 January 2018 12:30

the problem is that in ssh you run the command ad user PI, but domoticz runs as root for which (probably) there is no SSH key exchange between the 2 servers.

try with
os.execute('su pi ssh user@host -p port sudo reboot')

or log as root and connect the remote server the first time to save the key

ciao
M
The most dangerous phrase in any language is:
"We always done this way"

Post Reply

Who is online

Users browsing this forum: kmccor and 6 guests