Skip to content

Question: set cwd for executing lua script #271

@emcek

Description

@emcek

Hello,
I need run local lua script (which I can't change)i.e. c:\lua_stuff\some_proj\local.lua I want use lupa.
Can I pass file directly to lupa or use something like:

import lupa.luajit21 as lupa
lua = lupa.LuaRuntime()
with open('c:\\lua_stuff\\some_proj\\local.lua', 'r') as lua_file:
    lua_script = lua_file.read()
lua.execute(lua_script)
result = lua.globals().result
print(result)

But there is a problem because local.lua use relative paths so in order to run it I need be in c:\lua_stuff\ directory

PS C:\lua_stuff> lua .some_proj\local.lua

and since script do to return anything, can I check return code or something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions