SSH OnFileUploaded and SSH OnFileDownLoaded

You can share your Lua Scripts with everybody here.

SSH OnFileUploaded and SSH OnFileDownLoaded

Postby kirikou » Fri Sep 13, 2013 3:35 pm

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.
kirikou
 
posts 9
 
joined Wed Aug 07, 2013 9:20 am

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Postby FTP » Mon Sep 16, 2013 7:37 am

Just need to modify the first line into:

Code: Select all
math.randomseed(os.time())
math.random()
FTP
Site Admin
 
posts 1232
 
joined Tue Sep 29, 2009 6:09 am

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Postby kirikou » Wed Oct 02, 2013 2:47 pm

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.
kirikou
 
posts 9
 
joined Wed Aug 07, 2013 9:20 am

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Postby FTP » Sat Oct 12, 2013 1:08 pm

Just modify the first two lines into:

Code: Select all
math.randomseed(os.time())
n = c_GetTimeUS()
FTP
Site Admin
 
posts 1232
 
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