This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Download file .lp of logic machine automatic
#7
Hi,

What you also can do is write the file to your website's ftp, now you post the file to your local FTP (user folder on Apps FTP) and that's not helping your SD cards life cycle.

I also included a sample on how to created the .csv file on your external ftp location (:

Code:
require('socket.ftp')

-- ftp file
ftpfile = string.format('ftp://username:password@123.45.67.89/wwwroot/yourwebsitefolder/lmobjectdata.csv')
 
-- csv buffer
buffer = { '"name","address","updatetime"' } -- add more fields if you like

for _, row in ipairs(grp.all()) do
 csv = string.format('%q,%q,%q', row.name, row.address, row.updatetime) -- add more fields if you like
 table.insert(buffer, csv)
end

-- upload to ftp only when there's data in buffer
if #buffer > 1 then
 result, err = socket.ftp.put(ftpfile, table.concat(buffer, '\r\n'))
end

-- error while uploading
if err then
 alert('FTP upload error: %s', tostring(err))
end

You can run this from a scheduled or resident script.

BR,

Erwin
Reply


Messages In This Thread
RE: Download file .lp of logic machine automatic - by Erwin van der Zwart - 11.09.2017, 20:02

Forum Jump: