Hi,
my question coud be considered as implying a wide spectrum of answers, but I'm struggling to call php script in a lua (dzVents) script under Windows.
I've googled, tried to find relevant information in this forum, and I'm not able to find a tutorial for a dummy like me.
Specifically
- what should I need to install on my hardware hosting Domoticz (Wamp?)
- where scripts need to be saved? (on the Scripts folder from Domoticz? Posslble elsewhere?)
- are there specific commands to be called ? (on the os.execute() of the lua script ? on the header of the php script?)
Any kindly help, answers, link to tutorial will be very much appreciated!
Thanks!
G.
[Windows] Calling php script from dzVents
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: [Windows] Calling php script from dzVents
php is from dzVents perspective an os command. You can execute a php using os.execute or io.popen.
You can find within this forum and on internet many examples any how to use os.execute or io.popen but please note that the domoticz event system (and therewith dzVents) is single threaded. This means that unless you call your php and force it to the background the entire eventsystem of domotizc will wait (and eventually crash) until your php has returned control.
Out of curiosity; what do you want the php to do ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: [Windows] Calling php script from dzVents
Hi Wareen,
indeed the purpose is to call a php script from a dzVent script. I've understood such is doable with lua / os.execute(), but I'm totally unclear on the prerequisite and syntax on Win10. I've read documentation and forum regarding this, but this is mainly based on Linux.
I've written a very short script with dzVents to backup the Domoticz database daily and monthly, on a folder out of the Domoticz folder. This folder is located at the root of my hard-disk and synchronized with Google Drive. However I want to find out a solution to delete files after X days or months. I think lua is not able to handle file unless to intall the lfs library. The php script will act as a janitor.
I like to play with this, this is therefore more a challenge rather than a critical stuff.
Thanks!
G.
indeed the purpose is to call a php script from a dzVent script. I've understood such is doable with lua / os.execute(), but I'm totally unclear on the prerequisite and syntax on Win10. I've read documentation and forum regarding this, but this is mainly based on Linux.
I've written a very short script with dzVents to backup the Domoticz database daily and monthly, on a folder out of the Domoticz folder. This folder is located at the root of my hard-disk and synchronized with Google Drive. However I want to find out a solution to delete files after X days or months. I think lua is not able to handle file unless to intall the lfs library. The php script will act as a janitor.
I like to play with this, this is therefore more a challenge rather than a critical stuff.
Thanks!
G.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: [Windows] Calling php script from dzVents
Lua / dzVents can handle files via the os.execute or io.popen calls. In fact the complete os and io Lua libraries are available in domoticz Lua / dzVents.ghandii wrote: ↑Sunday 12 April 2020 15:37 indeed the purpose is to call a php script from a dzVent script. I've understood such is doable with lua / os.execute(), but I'm totally unclear on the prerequisite and syntax on Win10. I've read documentation and forum regarding this, but this is mainly based on Linux.
io library tutorial , os library tutorial
Syntax of the os.execute / io.pope commands on Windows should not be different compared to Linux but of course you can only call programs . scripts / commands available on Windows. Also you have to be aware of the difference in pathnames.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: [Windows] Calling php script from dzVents
ok was not so complicated...
1. downloaded and unzipped php binaires on a "c:/php" folder
2. add "C:\php" to the PATH system variable
3. and... that's it.
Works fine when I use the lua command os.execute("c:/php/php.exe c:/test/script.php")
However I do not understand why os.execute("php c:/test/script.php") does not work. Same command when I use the command prompt in Win10 executes properly the script.
Any though why the os.execute does not execute this?
Btw wareen, I was aware lua is able to create/rename/delete files. However I dit not find any function which could by an equivalent of php function filectime()...
Thanks!
A.
1. downloaded and unzipped php binaires on a "c:/php" folder
2. add "C:\php" to the PATH system variable
3. and... that's it.
Works fine when I use the lua command os.execute("c:/php/php.exe c:/test/script.php")
However I do not understand why os.execute("php c:/test/script.php") does not work. Same command when I use the command prompt in Win10 executes properly the script.
Any though why the os.execute does not execute this?
Btw wareen, I was aware lua is able to create/rename/delete files. However I dit not find any function which could by an equivalent of php function filectime()...
Thanks!
A.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: [Windows] Calling php script from dzVents
Most of the time you see this type of behavior it has to do with different env. for programmatic access or user access.
However I dit not find any function which could by an equivalent of php function filectime()...
[/quote]
Would
os.execute('dir /TW ' .. filename ) -- work for you ? ( Last write time )
or
os.execute('dir /TC ' .. filename ) -- Creation time
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: [Windows] Calling php script from dzVents
I tried to use dir /TW with the Win10 command prompt, and get result.
However, it seems this must be hereafter parsed to convert this result into a timestamp (and use io.popen() instead?).
Anyway, works fine with c:/php/php.exe, any further would be fine-tuning...
G.
However, it seems this must be hereafter parsed to convert this result into a timestamp (and use io.popen() instead?).
Anyway, works fine with c:/php/php.exe, any further would be fine-tuning...
G.
Who is online
Users browsing this forum: No registered users and 0 guests