bmw318
Posts: 13
Joined: Tue Aug 16, 2016 8:23 am

reading directory from pc on rpi with python

Mon Sep 26, 2016 12:11 pm

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.

cscuilla
Posts: 58
Joined: Tue Apr 26, 2016 6:35 pm

Re: reading directory from pc on rpi with python

Mon Sep 26, 2016 6:38 pm

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)

User avatar
DougieLawson
Posts: 36524
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: reading directory from pc on rpi with python

Mon Sep 26, 2016 7:33 pm

Share the folder from your PC, mount it as a samba/cifs share on your RPi.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

tom.slick
Posts: 190
Joined: Wed Jan 06, 2016 9:23 pm

Re: reading directory from pc on rpi with python

Tue Sep 27, 2016 8:36 am

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.

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: reading directory from pc on rpi with python

Tue Sep 27, 2016 9:42 am

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.

bmw318
Posts: 13
Joined: Tue Aug 16, 2016 8:23 am

Re: reading directory from pc on rpi with python

Sat Oct 01, 2016 5:17 pm

Thank you all. Will get in to this but I'm new in python.....

bmw318
Posts: 13
Joined: Tue Aug 16, 2016 8:23 am

Re: reading directory from pc on rpi with python

Mon Oct 03, 2016 12:20 pm

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.

richrarobi
Posts: 271
Joined: Sun Feb 08, 2015 1:13 pm

Re: reading directory from pc on rpi with python

Sat Oct 22, 2016 6:52 pm

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.

Return to “Python”