mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
218 lines
8.2 KiB
Plaintext
218 lines
8.2 KiB
Plaintext
// $$HEADER$$
|
|
The advanced shell
|
|
------------------
|
|
The advanced shell is an extension to the link:simple_shell.html[simple shell]. It adds some new
|
|
features to the simple shell:
|
|
|
|
- file masks
|
|
- more file operations (rename and move)
|
|
- recursive operations (for example recursive copies of directories)
|
|
|
|
A detailed description of the advanced shell commands and the structure of the file masks are given below.
|
|
|
|
[width="90%", cols="^, ^, ^, ^", grid="none"]
|
|
|==============================================================================================
|
|
| link:#cmd_help[help] | link:#cmd_ver[ver] | link:#cmd_recv[recv] | link:#cmd_lua[lua]
|
|
| link:#cmd_ls[ls] | link:#cmd_ls[dir] | link:#cmd_cat[cat] | link:#cmd_cat[type]
|
|
| link:#cmd_cp[cp] | link:#cmd_exit[exit] | link:#cmd_wofmt[wofmt] | link:#cmd_mkdir[mkdir]
|
|
| link:#cmd_rm[rm] | link:#cmd_mv[mv] | |
|
|
|==============================================================================================
|
|
|
|
File masks
|
|
----------
|
|
|
|
WARNING: Read this section carefully, eLua's idea of file masks ia different from what you might have
|
|
encountered in various operating systems.
|
|
|
|
The advanced shell supports file masks for various file operations (for example _cp_). A file mask can
|
|
match zero, one or more files. In order to match more than one file, it uses two special characters:
|
|
|
|
- _?_: this matches *exactly one character*
|
|
- _*_: this matches *zero or more characters*, non-greedy (it stops at the first non-special character).
|
|
Any *?* characters immediately following the *** will be ignored.
|
|
|
|
This is probably best understood by some examples. Given the filenames below:
|
|
|
|
-----
|
|
a
|
|
ab
|
|
abcd
|
|
abba
|
|
aaba
|
|
aaab
|
|
bbbcd
|
|
dccdb
|
|
-----
|
|
|
|
this is how various file masks work:
|
|
|
|
- _*_ : all the files above
|
|
- _a*_ : a, ab, abcd, abba, aaba, aaab
|
|
- _a*b_ : ab, aaab
|
|
- _a*?b_ : ab, aaab
|
|
- _a*b?_ : aaba
|
|
- _*b*_ : ab, abcd, abba, aaba, aaab, bbbcd, dccdb
|
|
- _????_ : abcd, abba, aaba, aaab
|
|
- _a?*b_ : aaab
|
|
|
|
[[cmd_help]]
|
|
help
|
|
~~~~
|
|
By itself, it shows a list of all shell commands. If a shell command is given after *help*, it displays
|
|
detailed information about the given command. Examples:
|
|
|
|
------
|
|
# help
|
|
# help ls
|
|
------
|
|
|
|
[[cmd_ver]]
|
|
ver
|
|
~~~
|
|
Print the version of the eLua image installed on the board. If the image is not an official one, an
|
|
abbreviation of the git SHA1 revision used for building the image will be shown in the version number.
|
|
|
|
[[cmd_recv]]
|
|
recv
|
|
~~~~
|
|
Allows you to receive from the PC running the terminal emulator program, a Lua file (either source or compiled
|
|
bytecode) via XMODEM and either execute it on your board or save it to a file. To use this feature, your eLua
|
|
target image must be built with support for XMODEM (see link:building.html[building] for details). Also, your
|
|
terminal emulation program must support sending files via the XMODEM protocol. Both XMODEM with checksum
|
|
and XMODEM with CRC are supported, but only XMODEM with 128 byte packets is allowed (XMODEM with 1K packets won't work).
|
|
|
|
To start the transfer, enter *recv* at the shell prompt. eLua will respond with "Waiting for file ...". At this point
|
|
you can send the file to the eLua board via XMODEM. eLua will receive and execute the file. Don't worry when you
|
|
see 'C' characters suddenly appearing on your terminal after you enter this command, this is how the XMODEM transfer
|
|
is initiated. If you want to save the data to a file instead of executing it, use *recv <filename>* instead.
|
|
|
|
Since XMODEM is a protocol that uses serial lines, this command is not available if you're running your console
|
|
over TCP/IP instead of a serial link. If you'd like to send compiled bytecode to eLua instead of source code,
|
|
please check link:using.html#cross[this section] first. Examples:
|
|
|
|
--------------------
|
|
# recv
|
|
# recv /mmc/temp.lua
|
|
--------------------
|
|
|
|
[[cmd_lua]]
|
|
lua
|
|
~~~
|
|
This command allows you to start the Lua interpreter, optionally passing command line parameters, just as you would do
|
|
from a desktop machine. There are some differences from the desktop Lua version in command line parsing:
|
|
|
|
- the command line can't be longer than 50 chars
|
|
- character escaping is not implemented. For example, the next command won't work because of the ' (simple quotes) escape sequences:
|
|
|
|
eLua# lua -e 'print(\'Hello, World!\')' -i
|
|
Press CTRL+Z to exit Lua
|
|
lua: (command line):1: unexpected symbol near ''
|
|
+
|
|
However, if you use both '' (simple quotes) and "" (double quotes) for string quoting, it will work:
|
|
|
|
eLua# lua -e 'print("Hello, World")' -i
|
|
Press CTRL+Z to exit Lua
|
|
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
|
|
Hello, World
|
|
|
|
- if you want to execute a file from the link:"arch_romfs.html"[ROM file system] (or from another file system), remember to prefix it
|
|
with _/rom_. For example, to execute *hello.lua*, do this:
|
|
|
|
eLua# lua /rom/hello.lua
|
|
|
|
[[cmd_ls]]
|
|
ls or dir
|
|
~~~~~~~~~
|
|
Shows a list of all the files in the file systems used by eLua, as well as their size and the total size of the given file system.
|
|
Syntax:
|
|
|
|
------------------
|
|
# ls [<path>] [-R]
|
|
------------------
|
|
|
|
If *path* is given, the listing is restricted to the file mask specified by *path*. If *-R* is given, *ls* will recurse through all
|
|
the directories in *path* or through all the directories in all the available filesystems if *path* is not specified.
|
|
|
|
[[cmd_cat]]
|
|
cat or type
|
|
~~~~~~~~~~~
|
|
Prints the content of (usually text) files on the console. Examples:
|
|
|
|
-------------------------------------
|
|
eLua# cat /rom/test.lua /mmc/temp.txt
|
|
eLua# cat /mmc/autorun.lua
|
|
-------------------------------------
|
|
|
|
[[cmd_cp]]
|
|
cp
|
|
~~
|
|
Copies a file or a directory. This command can be used to copy data between different file systems (for example between the MMC file
|
|
system and the RFS file system). Syntax:
|
|
|
|
-------------------------------------
|
|
# cp <src> <dest> [-R] [-f] [-c] [-s]
|
|
-------------------------------------
|
|
|
|
- *<src>* is the source file or directory. It can be a file mask.
|
|
- *<dest>* is the destination. If it does not exist, it will be created. It can't be a file mask.
|
|
- *-R*: (optional) copy files and directories recursively.
|
|
- *-f*: (optional) force file overwrite on *<dest>*. The default is to ask for confirmation before overriding.
|
|
- *-c*: (optional) confirm each file copy operation.
|
|
- *-s*: (optional) run the command normally, but don't actually copy anything. Useful to check the outcome of the operation before
|
|
actually executing it.
|
|
|
|
[[cmd_exit]]
|
|
exit
|
|
~~~~
|
|
Exits the shell. This only makes sense if eLua is compiled with terminal support over TCP/IP , as it closes the telnet session to the
|
|
eLua board. Otherwise it just terminates the shell and blocks forever until you reset your board.
|
|
|
|
[[cmd_wofmt]]
|
|
wofmt
|
|
~~~~~
|
|
"Formats" the link:arch_wofs.html[WOFS file system], erasing its current contents. The user is asked to confirm this operation.
|
|
|
|
[[cmd_mkdir]]
|
|
mkdir
|
|
~~~~~
|
|
Creates a new directory. The filesystem must have directory support in order fir this to work. Example:
|
|
|
|
----------------
|
|
# mkdir /mmc/dir
|
|
----------------
|
|
|
|
[[cmd_rm]]
|
|
rm
|
|
~~
|
|
Removes files and directories. Syntax:
|
|
|
|
------------------------------
|
|
# rm <filemask> [-R] [-c] [-s]
|
|
------------------------------
|
|
|
|
- *<filemask>*: specify the file(s) or directories that are to be removed
|
|
- *-R*: (optional) remove directories recursively. Use this flag to remove a directory with *rm*
|
|
- *-c*: (optional) confirm each remove operation.
|
|
- *-s*: (optional) run the command normally, but don't actually remove anything. Useful to check the outcome of the operation before
|
|
actually executing it.
|
|
|
|
[[cmd_mv]]
|
|
mv
|
|
~~
|
|
Moves a file or a directory. This command can be used to move data between different file systems (for example between the MMC file
|
|
system and the RFS file system). Syntax:
|
|
|
|
-------------------------------------
|
|
# mv <src> <dest> [-R] [-f] [-c] [-s]
|
|
-------------------------------------
|
|
|
|
- *<src>* is the source file or directory. It can be a file mask.
|
|
- *<dest>* is the destination. If it does not exist, it will be created. It can't be a file mask.
|
|
- *-R*: (optional) move files and directories recursively.
|
|
- *-f*: (optional) force file overwrite on *<dest>*. The default is to ask for confirmation before overriding.
|
|
- *-c*: (optional) confirm each file move operation.
|
|
- *-s*: (optional) run the command normally, but don't actually move anything. Useful to check the outcome of the operation before
|
|
actually executing it.
|
|
|
|
// $$FOOTER$$
|