SSH OnFileUploaded and SSH OnFileDownLoaded

You can share your Lua Scripts with everybody here.
Post Reply
kirikou
Posts: 9
Joined: Wed Aug 07, 2013 9:20 am

SSH OnFileUploaded and SSH OnFileDownLoaded

Post by kirikou »

I want to trigger a LOG when UpLOaded each File by SSH. This is my code:

math.randomseed(os.time())
n = math.random(123456789, 987654321)

-- Generation of ZFILE ZS
if "%Name" ~= "super_user_tdx_esftp" then

local username = "%Name"
local sessionid = "%ConnectID"
local tempfilepath = "C:/" .. "TRADEXPRESS" .. "/" .. username .. "/" .. "ZS" .. n .. username .. sessionid
local f = io.open(tempfilepath , "a")
--
f:write("USERNAME=")
f:write("%Name")
f:write("\n")
--
f:write("LOGNAME=")
f:write(string.sub("%Name",1,string.find("%Name","_") - 1))
f:write("\n")
--
f:write("SUBNAME=")
f:write(string.sub("%Name",string.find("%Name","_") + 1))
f:write("\n")
--
f:write("ACCOUNT=")
f:write("")
f:write("\n")
--
f:write("REMOTE_HOSTNAME=")
f:write("%ClientVersion")
f:write("\n")
--
f:write("REMOTE_HOSTADDR=")
f:write("%IP")
f:write("\n")
--
f:write("REMOTE_LOGNAME=")
f:write("unknown")
f:write("\n")
--
f:write("DIRECTION=")
f:write("S")
f:write("\n")
--
f:write("TRANSFER=")
f:write("STOR")
f:write("\n")
--
f:write("ZFILE=")
f:write(tempfilepath)
f:write("\n")
--
f:write("DATAFILE=")
f:write("%PathName")
f:write("\n")
--
f:write("STATUS=")
f:write("OK")
f:write("\n")
--
f:write("#EOF")
f:write("\n")

f:close()

end

But the problem is that when a client UpLoad more than one file at the same time, i have only one LOG file created, so , I want that when a client UpLoad more than one file at the same time, each file has his own LOG File!!!
Please I wait for your answers
Your Welcome.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Post by FTP »

Just need to modify the first line into:

Code: Select all

math.randomseed(os.time())
math.random()
kirikou
Posts: 9
Joined: Wed Aug 07, 2013 9:20 am

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Post by kirikou »

Thanks you,

but it is not work all time, some time, it is work.
Other one, it is continue to create one LOGfile for several files upload at the same time by a client.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Post by FTP »

Just modify the first two lines into:

Code: Select all

math.randomseed(os.time())
n = c_GetTimeUS()
Post Reply