log uploaded files by each user to different files

You can share your Lua Scripts with everybody here.

log uploaded files by each user to different files

Postby sabbas » Tue Oct 23, 2012 8:02 am

Hi there,

We're evaluating Wing FTP. so far, core features are impressive. We want to automate as much as possible. To start with LUA script, I would like to do the following:

Create a %UserName%.%Date%.TXT when the user logs in.
track all file uploads and append to the above text file
close the file and send email as attachment. This shoud work even if the user is disconnected due to idle time.

is this possible? At present we are using a third-party tool to automate this.

Could someone please help me with a sample script in this scenario so that I can start with LUA?

Also, do you share database schema with the customers so that we can create custom reports?

Thanking you in advance.

regards,
Shereef
sabbas
 
posts 1
 
joined Tue Oct 23, 2012 7:55 am

Re: log uploaded files by each user to different files

Postby FTP » Thu Oct 25, 2012 5:01 am

You can add the following script into the event "OnFileUploaded":
Code: Select all
local username = "%Name"
local sessionid = "%ConnectID"
local tempfilepath = "C:/" .. username .. "_" .. sessionid .. "_upload"
local f = io.open(tempfilepath , "a")
f:write("%PathName")
f:write("\n")
f:close()



And then add the following script into the event "OnUserDisconnect":
Code: Select all
local username = "%Name"
local sessionid = "%ConnectID"
local tempfilepath = "C:/" .. username .. "_" .. sessionid .. "_upload"
local f = io.open(tempfilepath, "r")
if f ~= nil then
   local filelist = f:read("*a")
   f:close()
   c_SendMail("xxxx@gmail.com","file upload","user %Name have been uplaoded files:\n" .. filelist,"","SMTP1")
   os.remove(tempfilepath)
end
FTP
Site Admin
 
posts 1220
 
joined Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 2 guests