lua-users home
lua-l archive

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



On 11-Oct-05, at 4:29 PM, David Given wrote:

I have an interesting problem involving one of my projects on Unix.

The reasons why are complicated, but my project boils down to needing to run a
Lua script, passed in on stdin, while giving the script arguments.

You could always do this:

$ cat > Lua
#!/usr/bin/env lua51
local c, err = loadstring(io.read"*a")
if c then c(...) else print(err); os.exit(1) end
^D

$ chmod a+x Lua

$ echo "for k,v in pairs(arg) do print(k, v) end" | ./Lua a b
1       a
2       b
-1      lua51
0       ./Lua