Skip to content
Thomas E. Horner edited this page Mar 12, 2019 · 34 revisions

Lua RTOS has an integrated shell that allows you to execute 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 shell command are organised into the following categories:

Utility commands

clear

Clear the terminal screen.

luac source [destination]

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

File system commands

cat file

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
/ > 

cd directory

Change the working directory to directory.

/ > cd examples
/examples > 

cp source destination

Copy the source file to the destination file.

/ > cp autorun.lua autorun.old

edit filename

Edit the filename.

ls pattern

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

mkdir directory

Creates a new directory named directory in the current directory.

more file

Print the contents of file one screen at a time.

mv source destination

Move (rename) the source file to the destination file.

pwd

Print name of current/working directory.

/examples > pwd
/examples	
/examples > 

rm pattern

Remove the files that match the pattern.

Network commands

netstat

Prints information about the status of the network interfaces.

/ > netstat
wf: mac address 24:0a:c4:01:96:ec
   ip address 192.168.1.46 / netmask 255.255.255.0
   gw address 192.168.1.1
  ip6 address fe80:0000:0000:0000:260a:c4ff:fe01:96ec

en: mac address 00:00:00:00:00:00
   ip address 0.0.0.0 netmask 0.0.0.0
   gw address 0.0.0.0

ping host

Send ICMP ECHO_REQUEST to network hosts to test connectivity between Lua RTOS an the host.

/ > ping whitecatboard.org
PING whitecatboard.org (5.196.211.36): 32 data bytes
60 bytes from 5.196.211.36: icmp_seq=1 time=35.515 ms
60 bytes from 5.196.211.36: icmp_seq=2 time=39.351 ms
60 bytes from 5.196.211.36: icmp_seq=3 time=35.153 ms
60 bytes from 5.196.211.36: icmp_seq=4 time=35.429 ms
60 bytes from 5.196.211.36: icmp_seq=5 time=35.362 ms
60 bytes from 5.196.211.36: icmp_seq=6 time=35.490 ms
60 bytes from 5.196.211.36: icmp_seq=7 time=35.216 ms
60 bytes from 5.196.211.36: icmp_seq=8 time=35.389 ms
60 bytes from 5.196.211.36: icmp_seq=9 time=35.739 ms
60 bytes from 5.196.211.36: icmp_seq=10 time=35.223 ms
10 packets transmitted, 10 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 35.153/35.787/39.351/1.199 ms

System commands

dmesg

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.

passwd

Changes the root password, used to establish a ssh connection to Lua RTOS.

uptime

Prints the Lua RTOS up time (the time that Lua RTOS is up since last reboot).

/ > uptime
23:42 up  0:04:14

reboot

Reboot the system.

Clone this wiki locally