What command should I be using to launch a program from the Lua Intepreter?

徘徊边缘 提交于 2019-12-12 05:32:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!