11.09.2017, 20:02
(This post was last modified: 11.09.2017, 21:50 by Erwin van der Zwart.)
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 (:
You can run this from a scheduled or resident script.
BR,
Erwin
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