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.

Error not sending file via ftp service!
#1
Hi everybody !
I have this code to save the backup file to the NAS service (using the ftp protocol). On the Lm3 (I use version 20170424), I opened the ftp service (login successful)
On nas synology, i open ftp service (login successful, full privileges for fpt_user directory).
When running the script on LM3 it again error as shown below:
"string: 553 <fpt_user> LM_nha_mau_HN-2018.02.26_12-28.tar.gz: Permission denied."
Have you met this case yet? And where is the error?
Please help me !
Thank so much!

Attached Files Thumbnail(s)
       
Reply
#2
Are you sure it should be fpt_user, but not ftp_user?
Reply
#3
yes, I'm sure !
Sad

Attached Files Thumbnail(s)
   
Reply
#4
Have you checked with another FTP client if you can upload files to this account? Also check that you can upload to root folder, or only to a specific folder. You might have to adjust path in FTP upload script on LM.
Reply
#5
Thank admin !
I use script:
------------------
---------------
--Take a backup and ftp to NAS
-- name of backup file
src = 'LM_nha_mau_HN-' .. os.date('%Y.%m.%d_%H-%M') .. '.tar.gz'
-- where to put backup file on LM
dst = '/home/ftp/' .. src
-- where to put the backup on NAS
target = '<fpt_user>' .. src

-- prepare files for backup
os.execute('sh /lib/genohm-scada/web/general/backup.sh')

-- create archive
os.execute('cd /lib/genohm-scada/storage && tar -c -z -f ' .. dst .. ' ./')


-- load the ftp support
local ftp = require("socket.ftp")
local ltn12 = require("ltn12")

-- ftp to NAS
f, e = socket.ftp.put{
host = "100.100.100.99",
user = "fpt_user",
password = "gammajsc",
type = "i",
argument = target,
source = ltn12.source.file(io.open(dst, "rb"))

}
if (e) then
log (e)
log (f)
alert("Could not ftp: ", e, "\n")
end
log("ftp_backup")




-- cleanup
os.execute('cd /home/ftp && rm -rf backup_*')
os.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')
-----------------
Am I something wrong? Please help me
Reply
#6
Hi

Could it be that you configurered sftp?

If so try to use the adapted script below, but you also need a new FTP package which you can find here

please install updated package:
https://dl.openrb.com/lm-17/pkg/luasocke...21_mxs.ipk

Code:
require('socket.ftp')

-------------------------
-- CONFIG
-------------------------
FTP_TARGET_FOLDER =  ''
FTP_TARGET_IP =  ''
FTP_TARGET_LOGIN = ''
FTP_TARGET_PW = ''

-------------------------
-- FUNCTIONS
-------------------------

-- backup the config and transfer it to the nas
function backup()
 
 log("System Backup: started")

 --Take a backup and ftp to NAS
    -- name of backup file
    src = 'backup-' .. os.date('%Y.%m.%d_%H-%M') .. '.tar.gz'
    -- where to put backup file on LM
    dst = '/home/ftp/' .. src

    -- where to put the backup on NAS
    target = FTP_TARGET_FOLDER .. src

    -- prepare files for backup
    os.execute('sh /lib/genohm-scada/web/general/backup.sh')

    -- create archive
    os.execute('cd /lib/genohm-scada/storage && tar -c -z -f ' .. dst .. ' ./')


    -- ftp to NAS
 log("System Backup: transfering backup to NAS, host:" .. FTP_TARGET_IP .. ", target:" .. target)
 res, err = socket.ftp.put({
     host = FTP_TARGET_IP,
     user = FTP_TARGET_LOGIN,
     password = FTP_TARGET_PW,
     secure = true,
     datasecure = true,
     type = "i",
     argument = target,
     source = ltn12.source.file(io.open(dst, "rb")) })
 
    if (err) then
   logMsg = "System Backup: failed with error:"
   if (error) then
     logMsg = logMsg .. err
   else
     logMsg = logMsg .. "nil"
   end
   if (res) then
     logMsg = logMsg .. ", result:" .. res
   else
     logMsg = logMsg ..  ", result:nil"
   end
   log(logMsg)
   alert("System Backup: failed, could not ftp to NAS, host:" .. FTP_TARGET_IP .. ", target:" .. target)
   alert(logMsg)
    end
   
    -- cleanup
    os.execute('cd /home/ftp && rm -rf backup_*')
    os.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')

 log("System Backup: completed")

end
Reply
#7
Thank so much !
I'm will try !
Reply
#8
This line is probably incorrect:
Code:
target = '<fpt_user>' .. src

Try this:
Code:
target = 'fpt_user/' .. src

Or this:
Code:
target = src
Reply


Forum Jump: