lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello

	I need to write a script that checks for unused dynamic libraries,
so I can remove them and save space on an appliance.

Using scanelf, the input file is a list of executables and the dynamic
libraries it need:
============
exec1 lib1,lib2,lib3
exec2 lib1
etc.
============

Here's what I have to far, but I can't get split() to work to extract
the list of libraries from each line in the file:
============
execs = io.open("execs.txt","r")

while true do
        line = execs:read("*line")
        if not line then break end

        -- read everything after space
        start = line:find(" ")
        if start then
                libs = line:sub(start+1)
        else
                print("Space not found in " .. line)
                break
        end

        -- split list of libs: lib1,lib2,lib3

        -- "attempt to call field 'split' (a nil value)"
        -- libs=libs.split(",")

        -- "attempt to call global 'split' (a nil value)"
        -- libs = split(libs,",")

        -- "attempt to call field 'split' (a nil value)"
        libs = string.split(libs,",")

        for lib in libs do print(lib) end
end

execs:close()

============

I don't know what is causing this error: Does someone know?

Also, I'm confused about when to use : and ., eg. should I use
execs:read() or execs.read()?

Thank you.