Trying to run LUA Script got error 'popen' not supported-osx

Moderator: leecollings

trixwood

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by trixwood »

Can i suggest using Domoticz internal Weatherunderground and patch your script to use that.. and remove all other weatherunderground from the script...

(I can not see why it is in the script anyway, since the hardware was already available, it kinda double if you have both this script & weatherunderground as hardware... but anyway..)...

Check out:

http://domoticz.com/forum/viewtopic.php ... 100#p94028

http://domoticz.com/forum/viewtopic.php ... 100#p94042 and the surrounding posts...
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by DrMacabre »

You read my mind ;)
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by DrMacabre »

Hello,

What is the "r" for in your exemple ?

local config = io.open(tmpfile, "r")
trixwood

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by trixwood »

Read!

Have a look in the reference manual:

https://www.lua.org/manual/5.1/manual.html#pdf-io.open
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by DrMacabre »

Thank you. I start to feel im even understanding what i'm reading :D

still getting a nil value with this.

Code: Select all

tmpfile = os.tmpname()
       cmd = 'curl "http://www.ogimet.com/cgi-bin/getsynop?block='..WMOID..'&begin='..UTC..'"' .. ' > ' .. tmpfile
       if( DEBUG == 1) then print(cmd) end
       os.execute(cmd)
       local ogimet = io.open(tmpfile, "r")
       local synop = ogimet:read('*all')
       ogimet:close()
       if( DEBUG == 1) then print('ogimet:'..synop) end
trying my best to understand each line with the correct syntax but still...
trixwood

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by trixwood »

Well the idea is to execute curl, save its output in a temporary file, and read it back.

You can try to executing the command you printed with debug in the terminal to see if its correct...

I do not know where os.tmpname stores its file, and if you have rights there (it should be, but who knows) so you can also hardcode the tempfile
instead of using os.tmpname().

as example for my pi to my home folder:
tmpfile = /home/pi/sun.tmp
You should remove the temp files with

Code: Select all

os.remove(tmpfile)
if you are done with it, or else it will fill up your storage. and you should check your the temp folder printed with the debug, for the already existing temp files you created and delete those...

https://www.lua.org/manual/5.1/manual.h ... -os.remove
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by DrMacabre »

Image

:)

Dank u wel, i was so lost. It works fine with a hardcoded temp file. Dunno why not with a generated one.
trixwood

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by trixwood »

it probably wanted to write were it has no rights. Who knows... i should have opted for the hardcoded to begin with... anyway.

About the whole lux sensor. the thing is inaccurate as f anyway... especially if you ogmet station is not really close and you have clear skies and the station has not..,... better point a lux sensor to the sky yourself :-)
DrMacabre
Posts: 74
Joined: Monday 26 December 2016 16:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11590
Location: France
Contact:

Re: Trying to run LUA Script got error 'popen' not supported-osx

Post by DrMacabre »

Still better than nothing, the station is a few KM away. I will see how it works for a few days. Thanks again.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest