cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Lua in the Command Line

No ratings

Hello! I have just written a tutorial on how to set up Lua to be run from the command line. As many already know, there is no good way to debug Lua scripts as they are used in package deployment in Software Content Manager, and building such a debugger is a vast and difficult undertaking. As an alternative, running small portions of code in the command line to ensure they will work as expected is one way to verify the validity of the Lua syntax prior to attempting a deployment. Here are the steps to set up Lua as a command line tool:

 

  1. Grab the GCC compiler called TDM-GCC
  2. Run the exe file and follow the install instructions
    • Remember the install directory for this, as the attached install script will need to be configured in a later step
    • Default location in the install file is "C:\Program Files\TDM-GCC\"
    • Note: leaving the "Add to PATH" selected will allow you to compile C code on the command line as well by typing "gcc" (this is not required for this set-up)
  3. Download the Lua source code ​This comes as a ".tar.gz" file, which can be tricky to extract in Windows
    • Download 7zip for freeware which can unzip this type of archive
    • Extract the Lua source code and navigate to the top level directory which should just contain one folder named like "lua-x.x.x" where the x's refer to the version
  4. Download and extract the attached zip file containing the build file
  5. Copy the "build.cmd" file from this to the top level directory of the Lua source code
  6. Modify the configuration as needed:
    • Version number default is 5.3.4 (parameter is called lua_version)
    • GCC install path default is "C:\Program Files\TDM-GCC\bin" (parameter is called lua_build_dir)
  7. Double click the "build.cmd" file
    • A console window will appear with installation details
    • If you see the following, then it worked successfully:
  8. The "lua\" directory will be created in the same folder as the "build.cmd" file
  9. Copy the "lua\" directory to "C:\Program Files\"
  10. Open "Computer" > "System Properties" > "Advanced system settings"
  11. Click "Environment Variables" > "New..."
  12. Call the variable "LUA" and make the value "C:\Program Files\lua\bin"
  13. Find the "Path" variable and click "Edit..."
  14. At the end of what is already there (do NOT delete anything that is already there), add "%LUA%" (make sure there is a ";" between the previous path and this entry)
  15. Click "Ok" Open a new command prompt (has to be new to load the new path) and type "lua" to see if it works
  16. Example syntax test from Lua command line:

 

I hope this is helpful to people! Let me know if you have any questions!

Comments

There are also prebuild binaries for windows, if someone is interested in this: Lua Binaries Download I just downloaded them, upnpack them to program file and added bin to PATH variable.

Version history
Last update:
‎Apr 05, 2017 06:28 PM
Updated by:
Labels (2)