rename a datafile uploaded on wing ftp server

You can share your Lua Scripts with everybody here.

rename a datafile uploaded on wing ftp server

Postby rabindra » Mon Jan 05, 2015 1:49 pm

Hello
PLEASE I NEED THE HELP
I want that if i upload by SSH protocol ,a datafile on wing ftp server,
    a paramfile would be created with the complete path of datafile
    and if the name of datafile uploaded has ".filepart" extension, it would be renamed itself without ".filepart" extension

I know that I have to use: SSH OnFileUploaded event , i try this

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

-- Génération du ZFILE ZS
if "%Name" ~= "super_user_tdx_esftp" then

local username = "%Name"
local sessionid = "%ConnectID"
local tempfilepath = "C:/" .. "TRADEXPRESS" .. "/" .. "DATAFILES" .. "/" .. username .. "/" .. "ZS" .. n .. username .. sessionid .. "%ServUploadFiles"
local f = io.open(tempfilepath , "a")
local cpt=0
--
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")
--
local thefilepath = "%PathName"
f:write("DATAFILE=")
f:write(thefilepath)
f:write("\n")
--
f:write("STATUS=")
if string.find( thefilepath, ".filepart") then
f:write("KO")
else
f:write("OK")
end
f:write("\n")
--
f:write("#EOF")
f:write("\n")

f:close()
end

But it is not worked very well.
rabindra
 
1
 
Mon Jan 05, 2015 10:51 am

Re: rename a datafile uploaded on wing ftp server

Postby FTP » Thu Jan 08, 2015 2:59 am

So what's wrong with the above Lua script?
FTP
Site Admin
 
1876
 
Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 3 guests

cron