Page 1 of 1

SSH OnFileUploaded and SSH OnFileDownLoaded

Posted: Fri Sep 13, 2013 3:35 pm
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.

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Posted: Mon Sep 16, 2013 7:37 am
by FTP
Just need to modify the first line into:

Code: Select all

math.randomseed(os.time())
math.random()

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Posted: Wed Oct 02, 2013 2:47 pm
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.

Re: SSH OnFileUploaded and SSH OnFileDownLoaded

Posted: Sat Oct 12, 2013 1:08 pm
by FTP
Just modify the first two lines into:

Code: Select all

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