rshell - Remote Shell

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
User avatar
dhylands
Posts: 2775
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

rshell - Remote Shell

Post by dhylands » Fri May 22, 2015 1:00 am

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.

User avatar
pythoncoder
Posts: 2656
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: rshell - Remote Shell

Post by pythoncoder » Sat May 23, 2015 8:12 am

That promises to be a great way to work with the Pyboard! Very nice :)
Peter Hinch

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: rshell - Remote Shell

Post by danicampora » Sat May 23, 2015 9:00 am

Hey Dave, awesome!! Great job!

I will give it a try ASAP :-).

User avatar
pythoncoder
Posts: 2656
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: rshell - Remote Shell

Post by pythoncoder » Sat May 23, 2015 10:33 am

One point: it needs a recent version of Python - 3.3 or newer. Anyone running Debian "wheezy" will need to upgrade.
Peter Hinch

User avatar
dhylands
Posts: 2775
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: rshell - Remote Shell

Post by dhylands » Sat May 23, 2015 3:08 pm

Thanks for the reminder (about python 3) I'll add a note to the README

pfalcon
Posts: 1011
Joined: Fri Feb 28, 2014 2:05 pm

Re: rshell - Remote Shell

Post by pfalcon » Sun May 24, 2015 5:21 pm

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.
Be aware of https://pypi.python.org/pypi/colorama .

pfalcon
Posts: 1011
Joined: Fri Feb 28, 2014 2:05 pm

Re: rshell - Remote Shell

Post by pfalcon » Sun May 24, 2015 5:25 pm

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 ;-).

User avatar
dhylands
Posts: 2775
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: rshell - Remote Shell

Post by dhylands » Sun May 24, 2015 6:31 pm

Doing the ssh/scp thing should be pretty easy.

You can already do:

Code: Select all

./rshell.py some-rshell-command
so you can do this:

Code: Select all

./rshell.py cp foo.py /flash
or:

Code: Select all

./rshell.py repl
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.

manitou
Posts: 67
Joined: Wed Feb 25, 2015 12:15 am

Re: rshell - Remote Shell

Post by manitou » Sun May 24, 2015 10:06 pm

clever!

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.

User avatar
pythoncoder
Posts: 2656
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: rshell - Remote Shell

Post by pythoncoder » Mon May 25, 2015 9:41 am

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

Post Reply