log uploaded files by each user to different files

You can share your Lua Scripts with everybody here.
Post Reply
sabbas
Posts: 1
Joined: Tue Oct 23, 2012 7:55 am

log uploaded files by each user to different files

Post by sabbas »

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
FTP
Site Admin
Posts: 1918
Joined: Tue Sep 29, 2009 6:09 am

Re: log uploaded files by each user to different files

Post by FTP »

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
Post Reply