rshell - Remote Shell
rshell - Remote Shell
I'm happy to release rshell, a remote shell for MicroPython.
rshell is a python program which runs on the host and connects to the pyboard over uart or USB serial. No extra software needs to be isntalled on the pyboard. rshell uses the raw-repl to upload any python snippets it needs on the fly.
rshell doesn't need USB Mass Storage, and you can turn off USB Mass Storage if you desire.
rshell allows you to copy files to and from the pyboard's file system, show the contents of files, and to use the repl.
I've done most of my testing under Linux, and I did a small amount of testing under Windows using a cygwin version of python3 and the Win32 version of python3. So far, I haven't been able to get colorized output to work with the Win32 version of python3, but it seems to work properly with the cygwin version.
There is a --nocolor option to disable colorized output.
You can find rshell.py here: https://github.com/dhylands/upy-shell/t ... ter/rshell
You'll need getch.py and for convenience I also include pyboard.py (which is a copy of the one in micropython/tools/pyboard.py)
Note when using the REPL, I decided to make Control-X be the character which exits the REPL since Control-D does a soft-reboot of the pyboard and I didn't want to lose that functionality.
rshell is a python program which runs on the host and connects to the pyboard over uart or USB serial. No extra software needs to be isntalled on the pyboard. rshell uses the raw-repl to upload any python snippets it needs on the fly.
rshell doesn't need USB Mass Storage, and you can turn off USB Mass Storage if you desire.
rshell allows you to copy files to and from the pyboard's file system, show the contents of files, and to use the repl.
I've done most of my testing under Linux, and I did a small amount of testing under Windows using a cygwin version of python3 and the Win32 version of python3. So far, I haven't been able to get colorized output to work with the Win32 version of python3, but it seems to work properly with the cygwin version.
There is a --nocolor option to disable colorized output.
You can find rshell.py here: https://github.com/dhylands/upy-shell/t ... ter/rshell
You'll need getch.py and for convenience I also include pyboard.py (which is a copy of the one in micropython/tools/pyboard.py)
Note when using the REPL, I decided to make Control-X be the character which exits the REPL since Control-D does a soft-reboot of the pyboard and I didn't want to lose that functionality.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell - Remote Shell
That promises to be a great way to work with the Pyboard! Very nice
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell - Remote Shell
One point: it needs a recent version of Python - 3.3 or newer. Anyone running Debian "wheezy" will need to upgrade.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: rshell - Remote Shell
Thanks for the reminder (about python 3) I'll add a note to the README
Re: rshell - Remote Shell
Be aware of https://pypi.python.org/pypi/colorama .dhylands wrote:So far, I haven't been able to get colorized output to work with the Win32 version of python3, but it seems to work properly with the cygwin version.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: rshell - Remote Shell
Otherwise looks like great project indeed. It will be some time before I come to a chance to try it, but speculatively may give a suggestion to use an idiom of ssh/scp like interface.
Ah, and last time I checked, project description and README on github was very terse, it's worth making them descriptive enough so people could easily "get" how rshell is cool and what exactly it does .
Ah, and last time I checked, project description and README on github was very terse, it's worth making them descriptive enough so people could easily "get" how rshell is cool and what exactly it does .
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: rshell - Remote Shell
Doing the ssh/scp thing should be pretty easy.
You can already do:
so you can do this:
or:
So I could definitely do something like if you create a symlink of repl to rshell.py and run ./repl then it would automatcially enter repl (this would be ssh mode) and if you create a symlink for rcp to rshell.py then it would do the cp command.
Thanks for the colorama link - I'll take a look at that.
You can already do:
Code: Select all
./rshell.py some-rshell-command
Code: Select all
./rshell.py cp foo.py /flash
Code: Select all
./rshell.py repl
Thanks for the colorama link - I'll take a look at that.
Re: rshell - Remote Shell
clever!
works for me (Ubuntu 14.04, python 3.4).
works for me (Ubuntu 14.04, python 3.4).
Last edited by manitou on Tue May 26, 2015 10:56 am, edited 1 time in total.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: rshell - Remote Shell
This might save anyone running Debian or a Debian based distro with an older version of Python a bit of leg work. Download the Python 3.4.3 source from https://www.python.org/. Edit the SOURCE, ME and DEST lines of the script to provide locations for the download, your home directory and rshell.py. Ensure you have unxz installed. Then run the script as root. It builds and installs V3.4.3 without changing the system default, so existing Python applications should be unaffected.
Code: Select all
#! /bin/bash
SOURCE="/home/pete/Downloads"
ME="/home/pete"
DEST="/mnt/qnap2/python/rshell"
apt-get install build-essential
apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
apt-get install libdb5.1-dev libgdbm-dev libsqlite3-dev libssl-dev
apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
unxz $SOURCE/Python-3.4.3.tar.xz
tar -xf $SOURCE/Python-3.4.3.tar
cd Python-3.4.3/
./configure --prefix=/usr/local/opt/python-3.4.3
make
make install
cd /usr/local/opt/python-3.4.3/bin/
./pip3 install pyserial
echo "alias rshell='/usr/local/opt/python-3.4.3/bin/python3.4 $DEST/rshell.py'">> $ME/.bashrc
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.