How to instal the LFS library in WingFTP ?

Please post here if you have problems in using Wing FTP Server.
Post Reply
DomDis
Posts: 33
Joined: Sat Mar 18, 2023 7:44 pm

How to instal the LFS library in WingFTP ?

Post by DomDis »

I am very interested in use the LuaFileSystem LFS library. It was mentioned in this thread viewtopic.php?p=8328#p8328

The user FTP repled that the executable are here ==> https://github.com/luapower/lfs but there is no mention of how to install this.

Can you provide information on how to make this library usable

I want to execute something like the following

Code: Select all

require "lfs"

function dirtree(dir)
assert(dir and dir ~= "", "directory parameter is missing or empty")
if string.sub(dir, -1) == "/" then
dir=string.sub(dir, 1, -2)
end

local function yieldtree(dir)
for entry in lfs.dir(dir) do
if entry ~= "." and entry ~= ".." then
entry=dir.."/"..entry
local attr=lfs.attributes(entry)
coroutine.yield(entry,attr)
if attr.mode == "directory" then
yieldtree(entry)
end
end
end
end

return coroutine.wrap(function() yieldtree(dir) end)
end

-- example
for filename, attr in dirtree("/FTP/FTP-Repo/") do
print(attr.mode, filename)
end
when i try running this at the console I get the following error
lua>> dofile("/root/Test/try1.lua")
some error in /root/Test/try1.lua:1: module 'lfs' not found:
no field package.preload['lfs']
no file './lfs.lua'
no file '/usr/local/share/lua/5.1/lfs.lua'
no file '/usr/local/share/lua/5.1/lfs/init.lua'
no file '/usr/local/lib/lua/5.1/lfs.lua'
no file '/usr/local/lib/lua/5.1/lfs/init.lua'
no file '/usr/share/lua/5.1/lfs.lua'
no file '/usr/share/lua/5.1/lfs/init.lua'
no file '/wftpserver//lua/lfs.lua'
no file './lfs.so'
no file '/usr/local/lib/lua/5.1/lfs.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.1/lfs.so'
no file '/usr/lib/lua/5.1/lfs.so'
no file '/usr/local/lib/lua/5.1/loadall.so'!

How do I install this library unto my existing Wing FTP server ?
FTP
Site Admin
Posts: 2080
Joined: Tue Sep 29, 2009 6:09 am

Re: How to instal the LFS library in WingFTP ?

Post by FTP »

OK, LFS lib has no problem. Just download LFS binary lib from: https://github.com/luapower/lfs/blob/ma ... lib/lfs.so

And move the file "lfs.so" to the WingFTP's installation folder, then you can execute the above Lua script.

Note, if you want to get result from "Administrator -> Console", you need to remove all the comment lines (line 25 in your code).
DomDis
Posts: 33
Joined: Sat Mar 18, 2023 7:44 pm

Re: How to instal the LFS library in WingFTP ?

Post by DomDis »

FTP wrote: Sun Aug 20, 2023 3:17 am OK, LFS lib has no problem. Just download LFS binary lib from: https://github.com/luapower/lfs/blob/ma ... lib/lfs.so

And move the file "lfs.so" to the WingFTP's installation folder, then you can execute the above Lua script.

Note, if you want to get result from "Administrator -> Console", you need to remove all the comment lines (line 25 in your code).
Thank you so much !!! I will try as you say
DomDis
Posts: 33
Joined: Sat Mar 18, 2023 7:44 pm

Re: How to instal the LFS library in WingFTP ?

Post by DomDis »

FTP wrote: Sun Aug 20, 2023 3:17 am Note, if you want to get result from "Administrator -> Console", you need to remove all the comment lines (line 25 in your code).
The --example line

I know if I paste all the lines into the console the window (single for multi-line mode) the comments halt the script halts
if i write the line into a file and the on the console i issue the dofile("/root/myluascripts\[scriptname.lua]") where [scriptname.lua] is the name of the file containing the script. I ca have ans many comments as I want and all the line execute

Thank you for looking out for me I have struggled with this very thing in the past. I hear the multiline mode should work with comments but I can't figure it out. using a file works for me


May I ask when you say move it to the Wingftp installation folder - Which do you meant I'm on ubuntu so would it go into /wftpsever/lua ????

Code: Select all

/wftpserver/lua
root@ubftp:/wftpserver/lua# ll
total 104
drwxrwxr-x 2 gdcftp gdcftp  4096 Aug 18 17:37 ./
drwxrwxr-x 9 gdcftp gdcftp  4096 May  6 11:51 ../
-rw-rw-r-- 1 gdcftp gdcftp  6921 Mar  5 21:44 cgiadmin.lua
-rw-rw-r-- 1 gdcftp gdcftp  8778 Mar  5 21:44 cgi.lua
-rw-r--r-- 1 root   root    8778 Apr 18 10:57 cgi.lua.ORIGINAL
-rw-rw-r-- 1 gdcftp gdcftp  7758 Nov 22  2017 json.lua
-rw-rw-r-- 1 gdcftp gdcftp 39715 Mar 13 09:52 ServerInterface.lua
-rw-rw-r-- 1 gdcftp gdcftp  5041 Aug 11  2021 SessionModuleAdmin.lua
-rw-rw-r-- 1 gdcftp gdcftp  5136 Aug 11  2021 SessionModule.lua
DomDis
Posts: 33
Joined: Sat Mar 18, 2023 7:44 pm

Re: How to instal the LFS library in WingFTP ?

Post by DomDis »

DomDis wrote: Sun Aug 20, 2023 3:57 pm May I ask when you say move it to the Wingftp installation folder - Which do you meant I'm on ubuntu so would it go into /wftpsever/lua ????


That didn't work so I moved it to the root of the install dir of WingFTP /wftpserver


I'm not getting errors saying it can;t find the library so I think that worked but the script does have issues

I thank you for all you assistance !!!!!
Post Reply