Hello,
I'm trying this with Python, to create a setup page for this project:
http://www.domoticz.com/forum/viewtopic ... 40#p178879 and the challenge I'm having is that Domoticz internal webserver does not execute Python scripts outside its own management system.
I guess I could solve this using Apache or Nginx, but seems a bit overkill to install another server when Domoticz has already one. This is the architecture:
1.- I have a web setup page with multiple options for its nearly 50 I/Os, some of them have multiple options per I/O, hence the reason to create its own custom setup page
2.- From this page, it generates a configuration file that is pushed via UART to the guest micro-controllers on the main board.
3.- Similar for reading the status settings of the main board.
I also tried with PHP, same situation. The question, can I call from a web page within the www folder of Domoticz a python script and execute it?
Execute Python script from web via Domoticz internal server
Moderator: leecollings
-
- Posts: 953
- Joined: Sunday 22 January 2017 11:37
- Target OS: Windows
- Domoticz version: V2024.4
- Contact:
Re: Execute Python script from web via Domoticz internal server
Hi, have a python plugin for that that I'm calling PSExec ( if you see the reference

Let me know if you are interested, can provide it to you.
- EdddieN
- Posts: 510
- Joined: Wednesday 16 November 2016 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Scotland
- Contact:
Re: Execute Python script from web via Domoticz internal server
Yes interested! Are you able to trigger it from a web page?
11101101 - www.machinon.com
- EdddieN
- Posts: 510
- Joined: Wednesday 16 November 2016 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Scotland
- Contact:
Re: Execute Python script from web via Domoticz internal server
Ok, I saw your plugin, really nice! Just to advance for me, I get lost
To give you a more real example of what I'm tying, I have a simple website served by Domoticz webserver, this webpage produces a configuration file or similar with the above:
Which I need to send via serial port. I have a python/bash script that already pushes the data to the motherboard, however I cannot execute the script from the web itself... any ideas how to bypass this without having to install a new server?

To give you a more real example of what I'm tying, I have a simple website served by Domoticz webserver, this webpage produces a configuration file or similar with the above:
Code: Select all
4;1;1;0;24;1\n
4;1;1;0;25;99,345\n
4;1;1;0;26;30,38\n
4;2;1;0;24;1\n
4;2;1;0;25;99,345\n
4;2;1;0;26;30,38\n
4;3;1;0;24;1\n
4;3;1;0;25;99,345\n
4;3;1;0;26;30,38\n
4;4;1;0;24;1\n
4;4;1;0;25;99,345\n
4;4;1;0;26;30,38\n
4;5;1;0;24;2\n
4;5;1;0;25;99,345\n
4;5;1;0;26;30,39\n
4;6;1;0;24;2\n
4;6;1;0;25;99,345\n
4;6;1;0;26;30,39\n
4;7;1;0;24;2\n
4;7;1;0;25;99,345\n
4;7;1;0;26;30,39\n
4;8;1;0;24;2\n
4;8;1;0;25;99,345\n
4;8;1;0;26;30,39\n
11101101 - www.machinon.com
-
- Posts: 953
- Joined: Sunday 22 January 2017 11:37
- Target OS: Windows
- Domoticz version: V2024.4
- Contact:
Re: Execute Python script from web via Domoticz internal server
Hummm.. I think I see the one you're speaking.. not mine and I'm also lostEdddieN wrote: ↑Tuesday 01 May 2018 11:48 Ok, I saw your plugin, really nice! Just to advance for me, I get lost![]()
Which I need to send via serial port. I have a python/bash script that already pushes the data to the motherboard, however I cannot execute the script from the web itself... any ideas how to bypass this without having to install a new server?

Mine request that you send the command you want by doing a POST on specific port, so this can be made by curl and of course any web page.
curl example :
curl --data "ls -altr >$HOME/ls.lst" 192.168.1.20:9002
Do not be afraid about the code inside, do not have take time to clear it and made something better.. but work as it is.
you just need to change this line and put the command you want to allow:
Code: Select all
#
# Authorized commands, if not into the list, not executed
commandok=['samsungctl','dir','py', 'tt.cmd']
nohup sudo /bin/sh $1
- EdddieN
- Posts: 510
- Joined: Wednesday 16 November 2016 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Scotland
- Contact:
Re: Execute Python script from web via Domoticz internal server
Thanks!
I'll have to play with it a bit, I'll come back with feedback hopefully in a few days
I'll have to play with it a bit, I'll come back with feedback hopefully in a few days

11101101 - www.machinon.com
- EdddieN
- Posts: 510
- Joined: Wednesday 16 November 2016 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Scotland
- Contact:
Re: Execute Python script from web via Domoticz internal server
Just thinking aloud, what about forgetting about the whole web page served by Domoticz but actually building a plugin:
https://www.domoticz.com/wiki/Developin ... hon_plugin
From what I can see here http://www.domoticz.com/forum/viewtopic ... 65&t=21297 , python can access the UART of the Raspberry Pi (or any UART I guess), so I could create the setup page as a plugin, right?
If anyone has a simple way to explain how it works, I'll take it! as I'm really new to it, it is going to take me a while
https://www.domoticz.com/wiki/Developin ... hon_plugin
From what I can see here http://www.domoticz.com/forum/viewtopic ... 65&t=21297 , python can access the UART of the Raspberry Pi (or any UART I guess), so I could create the setup page as a plugin, right?
If anyone has a simple way to explain how it works, I'll take it! as I'm really new to it, it is going to take me a while

11101101 - www.machinon.com
Who is online
Users browsing this forum: No registered users and 1 guest