问题
I have been attempting to troubleshoot how to launch a program I write in Lua, and it seems to me that I should be launching the program from the Lua Interpreter. The First Edition of Programming in Lua tells me I should use the command prompt> lua hello.lua
. The name of my program is "hello.lua" and it is in the same folder as the Interpreter but I get the error message '=' expected near '>'. What command should I be using? Or am i doing something wrong?
回答1:
Under Windows (administrator console):
ftype Lua.File=C:\utils\lua.exe "%1" %*
(where c:\utils\lua.exe is the actual path of your Lua interpreter)
assoc .lua=Lua.File
Now, you can type: hello.lua directly at the command prompt
And, if in "Computer/Properties/Advanced/Environment Variables" (Win7 example) you add .LUA to the PATHEXT variable, you can simply type: hello at the command prompt, without the extension.
回答2:
(I guess you are on some Unix or POSIX system)
Just type lua hello.lua
; the prompt>
string is given by your shell (and the prompt is generally something different and configurable).
By typing literally prompt>
you are asking your shell to run a program -or a command- named prompt
and to redirect its stdout (to what follows the >
)
来源:https://stackoverflow.com/questions/34458941/what-command-should-i-be-using-to-launch-a-program-from-the-lua-intepreter