Provided by: pyboard-rshell_0.0.31-0ubuntu1_all
NAME
rshell - Remote Shell for a MicroPython board
SYNOPSIS
rshell [-b baud] [-p port] [--rts 1|0] [--dtr 1|0] [-u user] [-w password] [-e editor] [-f filename] [-d] [-n] [-l] [-a] [--buffer-size bytes] [--wait seconds] [--timing] [--quiet] [cmd] rshell -h rshell -V
DESCRIPTION
rshell is a simple shell which runs on the host and uses MicroPython's raw-REPL to send python snippets to the pyboard in order to get filesystem information, and to copy files to and from MicroPython's filesystem. It also has the ability to invoke the regular REPL, so rshell can be used as a terminal emulator as well. NOTE: With rshell you can disable USB Mass Storage and still copy files into and out of your pyboard. When using the commands, the /flash directory, and the /sdcard directory (if an sdcard is inserted) are considered to be on the pyboard, and all other directories are considered to be on the host. For an ESP based board you can only reference its directory by using the board name e.g. /pyboard etc. NOTE: rshell requires a fairly recent version of the MicroPython firmware, specifically one which contains the ubinascii.unhexlify command which was added May 19, 2015 (v1.4.3-28-ga3a14b9 or newer). If your version of the firmware isn't new enough, then you'll see an error message something like this: $ rshell rshell needs MicroPython firmware with ubinascii.unhexlify
OPTIONS
-h, --help Show a help message and exit -a, --ascii On certain platforms the raw REPL mode is unreliable with particular sequences of binary characters. Specifying --ascii enables the transfer of binary files to such platforms. It does this by encoding the data as ASCII hex. -b, --baud=BAUD Sets the baud rate to use when talking to the pyboard over a serial port. If no baud is specified, then the baudrate from the RSHELL_BAUD environment variable is used. If the RSHELL_BAUD environment variable is not defined then the default baudrate of 115200 is used. --buffer-size=BUFFER_SIZE Sets the buffer size used when transferring files between the host and the pyboard. If no buffer size is specified, then the value from the RSHELL_BUFFER_SIZE environment variable is used. If the RSHELL_BUFFER_SIZE environment variable is not defined, then the default of 512 is used. -d, --debug Turns on debugging. This allows you to see the script which is sent over the raw REPL and the response received. --dtr=[0|1|True|False] Sets the state of the DTR line when opening the serial port. This may also be defaulted from the RSHELL_DTR environment variable. -e, --editor=EDITOR Specifies the editor to use with the edit command. If no editor is specified, then the following environment variables will be searched: RSHELL_EDITOR,VISUAL, and EDITOR. If none of those environment variables is set then vi will be used. -f, --file=FILENAME Specifies a file of rshell commands to process. This allows you to create a script which executes any valid rshell commands. -n, --nocolor By default, rshell uses ANSI color escape codes when displaying the prompt and ls output. This option allows colorized output to be disabled. -p, --port=PORT Specifies the serial port which should be used to talk to the MicroPython board. You can set the RSHELL_PORT environment variable to specify the default port to be used, if --port is not specified on the command line. --quiet This option causes the Connecting messages printed when rshell starts to be suppressed. This is mostly useful for the test scripts. --rts=[0|1|True|False] Sets the state of the RTS line when opening the serial port. This may also be defaulted from the RSHELL_RTS environment variable. --timing If the timing option is specified then rshell will print the amount of time that each command takes to execute. -u, --user=USER Specifies the username to use when logging into a WiPy over telnet. If no username is specified, then the username from the RSHELL_USER environment variable is used. If the RSHELL_USER environment variable doesn't exist then the default username 'micro' is used. -w, --password=PASSWORD Specified the password to use when logging into a WiPy over telnet. If no password is specified, then the password from the RSHELL_PASSWORD environment variable is used. If the RSHELL_PASSWORD environment variable doesn't exist then the default password 'python' is used. --wait If a port is specified defines how long rshell will wait for the port to exist and for a connection to be established. The default is 0 seconds specifying an immediate return. cmd If a command is specified, then that command will be executed and rshell will exit.
FILE SYSTEM
rshell can be connected to multiple pyboards simultaneously. If the board module exists on the pyboard (i.e. a file named board.py somewhere in the module search path) and it contains an attribute called name (e.g. name = "myboard") then the pyboard will use that name. If the board module can't be imported then the board will be named, pyboard or wipy. Names will have -1 (or some other number) to make the board name unique. You can access the internal flash on the first board connected using /flash and the sd card on the first board connected can be accessed using /sd. For all other connected pyboards, you can use /board-name/flash or /board-name/sd (you can see the board names using the boards command). The boards command will show all of the connected pyboards, along with all of the directories which map onto that pyboard.
COMMANDS
args [ARGUMENTS...] Debug function for verifying argument parsing. This function just prints out each argument that it receives. boards boards Lists all of the boards that rshell is currently connected to, their names, and the connection. You can give a custom name to a board with either copying over a board.py file or using the echo command, e.g. echo 'name="myboard"' > /pyboard/board.py Remember to exit rshell and re-enter to see the change. cat FILENAME... Concatenates files and sends to stdout. cd DIRECTORY Changes the current directory. ~ expansion is supported, and cd - goes to the previous directory. connect TYPE TYPE_PARAMS connect serial PORT [BAUD] connect telnet IP-ADDR-OR-NAME Connects a pyboard to rshell. rshell can be connected to multiple pyboards simultaneously. cp SOURCE... DEST cp [-r|--recursive] [SOURCE|SRC_DIR]... DIRECTORY cp [-r|--recursive] PATTERN DIRECTORY Copies the SOURCE file to DEST. DEST may be a filename or a directory name. If more than one source file is specified, then the destination should be a directory. Directories will only be copied if --recursive is specified. A single pattern may be specified, in which case the destination should be a directory. Pattern matching is performed according to a subset of the Unix rules (see below). Recursive copying uses the rsync command (see below): where a file exists on source and destination, it will only be copied if the source is newer than the destination. echo TEXT... Display a line of text. edit FILENAME If the file is on a pyboard, it copies the file to host, invokes an editor and if any changes were made to the file, it copies it back to the pyboard. The editor which is used defaults to vi, but can be overridden using either the --editor command line option when rshell is invoked, or by using the RSHELL_EDITOR, VISUAL or EDITOR environment variables (they are tried in the order listed). filesize FILE Prints the size of the file, in bytes. This function is primarily for testing. filetype FILE Prints the type of file (dir or file). This function is primarily for testing. help [COMMAND] List available commands with no arguments, or detailed help when a command is provided. ls [-a] [-l] [FILE|DIRECTORY|PATTERN]... List directory contents. If --long is specified, a long listing format is used. --all may be specified to show hidden files. Pattern matching is performed according to a subset of the Unix rules (see below). mkdir DIRECTORY... Creates one or more directories. repl [BOARD-NAME] [~ LINE] [~] Enters into the regular REPL with the MicroPython board. Use Control-X to exit REPL mode and return the shell. It may take a second or two before the REPL exits. If you provide a BOARD-NAME then rshell will connect to that board, otherwise it will connect to the default board (first connected board). If you provide a tilde followed by a space (~ ) then anything after the tilde will be entered as if you typed it on the command line. If you want the repl to exit, end the line with the ~ character. For example, you could use: rshell repl \~ pyb.bootloader\(\)\~ and it will boot the pyboard into DFU. If you want to execute multiple Python commands these should be separated by the ~ character (not the ; character): rshell repl \~ import mymodule \~ mymodule.run\(\) NOTE: Escaping (or quoting) of tilde (and parentheses) is likely to be necessary to prevent shell-expansion if you are running rshell from bash. Such escaping is not required if running repl from within an rshell session. rm [-f|--force] FILE... rm [-f|--force] PATTERN rm -r [-f|--force] PATTERN rm -r [-f|--force] [FILE|DIRECTORY]... Removes files or directories (including their contents). A single pattern may be specified. Pattern matching is performed according to a subset of the Unix rules (see below). Directories can only be removed if the --recursive argument is provided. Beware of rm -r * or worse. rsync [-m|--mirror] [-n|--dry-run] [-q|--quiet] SRC_DIR DEST_DIR Recursively synchronises a source directory to a destination. Directories must exist. If --mirror is specified, files or directories will be removed from the destination if they are absent in the source. --dry-run can be specified to report what would be done without making any changes. Synchronisation is performed by comparing the date and time of source and destination files. Files are copied if the source is newer than the destination. shell [COMMAND] ! [COMMAND] The shell command can be abbreviated using the exclamation point. This will invoke a command, and return back to rshell. Example: !make deploy will flash the pyboard.
PATTERN MATCHING
This is performed according to a subset of the Unix rules. The limitations are that wildcards are only allowed in the rightmost directory of a path and curly bracket {} syntax is unsupported: *.py Match files in current directory with a .py extension. temp/x[0-9]a.* Match temp/x1a.bmp but not temp/x00a.bmp t*/*.bmp Invalid: will produce an error message {*.doc,*.pdf} Invalid: will produce an error message 2022-04-14 RSHELL(1)