rename a datafile uploaded on wing ftp server

You can share your Lua Scripts with everybody here.
Post Reply
rabindra
Posts: 1
Joined: Mon Jan 05, 2015 10:51 am

rename a datafile uploaded on wing ftp server

Post by rabindra »

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

Re: rename a datafile uploaded on wing ftp server

Post by FTP »

So what's wrong with the above Lua script?
Post Reply