Page 1 of 1

reading directory from pc on rpi with python

Posted: Mon Sep 26, 2016 12:11 pm
by bmw318
Hi,
I lnow there are Putty and Filezilla to read files on the RPI board and copy them on your PC but I want to do this in Python.
I want to write a program in Python to start activity (a measurement) on the RPI and retrieving the data, stored in the RPI, to my PC.

Are there any examples of doing that?

Thanks.

Re: reading directory from pc on rpi with python

Posted: Mon Sep 26, 2016 6:38 pm
by cscuilla
You can write to a file from python. See here..

http://www.pythonforbeginners.com/files ... -in-python

You can store this file on your Pi, or on your PC (as a network share)

Re: reading directory from pc on rpi with python

Posted: Mon Sep 26, 2016 7:33 pm
by DougieLawson
Share the folder from your PC, mount it as a samba/cifs share on your RPi.

Re: reading directory from pc on rpi with python

Posted: Tue Sep 27, 2016 8:36 am
by tom.slick
bmw318 wrote:Hi,
I lnow there are Putty and Filezilla to read files on the RPI board and copy them on your PC but I want to do this in Python.
I want to write a program in Python to start activity (a measurement) on the RPI and retrieving the data, stored in the RPI, to my PC.

Are there any examples of doing that?

Thanks.
Yes. https://docs.python.org/2/library/simplehttpserver.html
The simplehttpserver is a built-in module. Use your web browser to download files from the RPI (right click, save as).

It's very limited, only works one way, but is what you asked for.

Re: reading directory from pc on rpi with python

Posted: Tue Sep 27, 2016 9:42 am
by B.Goode
Another option:

SSH can be used to run a nominated script or application on the remote system.

There are existing Python library modules that allow you to easily establish a secure ssh connection from within a Python script. I think paramiko is one, there may be others.

Glue those two ideas together and maybe you have the basis of another solution.

Re: reading directory from pc on rpi with python

Posted: Sat Oct 01, 2016 5:17 pm
by bmw318
Thank you all. Will get in to this but I'm new in python.....

Re: reading directory from pc on rpi with python

Posted: Mon Oct 03, 2016 12:20 pm
by bmw318
Hi,
do i have to install paramiko on both the raspberry pi AND my laptop/pc ?

Regards.

B.Goode wrote:Another option:

SSH can be used to run a nominated script or application on the remote system.

There are existing Python library modules that allow you to easily establish a secure ssh connection from within a Python script. I think paramiko is one, there may be others.

Glue those two ideas together and maybe you have the basis of another solution.

Re: reading directory from pc on rpi with python

Posted: Sat Oct 22, 2016 6:52 pm
by richrarobi
I want to write a program in Python to start activity (a measurement) on the RPI and retrieving the data, stored in the RPI, to my PC.
You might find what you need in something like mqtt, or zeromq - messaging solutions.
What you describe does tend to look like you need an RPC style answer (or even just the simpler request/reply messaging).

viewtopic.php?f=31&t=123977&p=1033949&h ... c#p1033949
or
http://learning-0mq-with-pyzmq.readthed ... erver.html

SSH can appear a little "crude" with the need for authentication at each request (or the set up of security keys). You wouldn't have this issue with messaging.