When the Lua script on most systems starts arg contains the command from which the script was started. I have this file:
for k,v in pairs(arg) do
print(k,v)
end
When I run it like:
D:\>lua d:\commandArgs.lua
0 d:\commandArgs.lua
-1 lua
When I do:
D:\>lua commandArgs.lua
0 commandArgs.lua
-1 lua
This works fine for me in Windows and Linux as well. In the second case we do not get the path. To get the path can be system dependent. If you have the os library and popen function in your lua version, 1 way to get the path is:
cmd = os.execute("pwd") and "pwd" or "cd"
f = io.popen(cmd,"r")
path = f:read("*a")
f:close()
Milind