Automatic FTP synchronization (server to server transfer)

You can share your Lua Scripts with everybody here.

Automatic FTP synchronization (server to server transfer)

Postby FTP » Fri Dec 07, 2012 10:18 am

-- Description: Automatic FTP synchronization or backup (server to server transfer)
-- You should add the below scripts to the event manager -> FTP or HTTP OnFileUploaded
-- When a file is uploaded, it can be sent to one or two or even more FTP servers automatically
-- Author: Luke
-- Date: 2012-10-07

Code: Select all
require("socket.ftp")
require("socket.ltn12")

--send the file to the first FTP server
f, e = put{
  host = "192.168.0.100",
  user = "user1",
  password = "pass1",
  port = 21,
  argument = "/%FileName",
  source = source.file(io.open("%PathName", "rb"))
}

--send the file to the second FTP server
f, e = put{
  host = "192.168.0.105",
  user = "user2",
  password = "pass2",
  port = 21,
  argument = "/ftpfolder/%FileName",
  source = source.file(io.open("%PathName", "rb"))
}


Image


The above scripts use a modified version of luasocket library, you can download and unzip it into the working directory of Wing FTP Server. The download URL: http://www.wftpserver.com/bbsres/socket.zip
FTP
Site Admin
 
posts 1236
 
joined Tue Sep 29, 2009 6:09 am

Re: Automatic FTP synchronization or backup

Postby FTP » Fri Dec 07, 2012 10:25 am

You can also use the luasocket library for downloading a file:

Code: Select all
require("socket.ftp")
require("socket.ltn12")

f, e = get{
  host = "192.168.0.100",
  user = "USERNAME",
  password = "PASSWORD",
  port = 21,
  argument = "img111.jpg",
  sink  = sink.file(io.open("c:/img111.jpg", "wb"))
}
FTP
Site Admin
 
posts 1236
 
joined Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 1 guest