-
Notifications
You must be signed in to change notification settings - Fork 227
The shell
Lua RTOS has an integrated shell that allows you to execute certain commands in a linux similar way. The shell is disabled by default, but you can enable it typing os.shell(true) in the prompt or putting os.shell(true) in the system.lua file.
The following explains all the commands supported by the shell.
Clear the terminal screen.
luac is the Lua compiler. It translates programs written in the Lua programming language (source argument) into binary files ([destination] argument) that can be later loaded and executed.
The main advantages of precompiling chunks are: faster loading, protecting source code from accidental user changes, and off-line syntax checking.
Precompiling does not imply faster execution because in Lua chunks are always compiled into bytecodes before being executed. luac simply allows those bytecodes to be saved in a file for later execution.
destination argument is optional, and if it's not provided the compiled filename is the source filename postfixed with the "c" character.
Example:
-- Compile test.lua into test.luac file
luac test.lua test.luac
-- Compile test.lua into test.luac file
luac test.lua
Print the file on the standard output.
/ > cat system.lua
-- system.lua
--
-- This script is executed after a system boot or a system reset and is intended
-- for setup the system.
---------------------------------------------------
-- Main setups
---------------------------------------------------
os.loglevel(os.LOG_INFO) -- Log level to info
os.logcons(true) -- Enable/disable sys log messages to console
os.shell(true) -- Enable/disable shell
os.history(false) -- Enable/disable history
/ >
Change the working directory to directory.
/ > cd examples
/examples >
Copy the source file to the destination file.
/ > cp autorun.lua autorun.old
Lists directory contents of files and directories that matches the pattern.
/ > ls *.lua
f 0 autorun.lua
f 2446 system.lua
f 2445 config.lua
f 252 test.lua
f 280 test2.lua
Creates a new directory named directory in the current directory.
Move (rename) SOURCE to DESTINATION.
Print name of current/working directory.
/examples > pwd
/examples
/examples >
Remove FILE.
Print the syslog contents on the standard output.
Note: dmesg is only available if the underlying storage for your root filesystem is not the SPI FLASH.
Reboot the system.