Page 1 of 1

transfer files between two RPi through CATe5 cable

Posted: Thu Jun 25, 2015 4:26 pm
by Sorin_v2
Hi guys,

I'm in a dire need to know how to transfer a text/CSV file between two Raspberry Pis B+. This is part of an automated process which involves both Pis, meainng that the first Pi creates my file and the second one needs it to upload the data into a database. Everytime (every minute) data in the file is re-written, the file should be sent to the other RPi. The Pis are connected through an CATe5 cable like an ad hoc network.

Does anyone have any idea about how to do this? Or does anyone have a better idea about how to send this file between the RPis.

Thank you,
Sorin

Re: transfer files between two RPi through CATe5 cable

Posted: Thu Jun 25, 2015 4:51 pm
by DougieLawson
If RPi #2 is running a database why not get RPi #1 to connect as a remote database client and insert the data directly. It's trivial to do that with MySQL/MariaDB. Needs a tweak to the privileges tables and needs a tweak to /etc/mysql/my.cnf to get that running.

Although transfering a file is as simple as
scp /home/user1/localfilename user2@pi2:/home/user2/remotefilename
(You need to add the ssh private key for user1 on pi1 to /home/user2/.ssh/authorized_keys on pi2 to avoid the need to store a password.

The other way is to export the filesystem from pi2 as a NFS (or if you insist a CIFS (which isn't ideal)) share and mount it on pi1. Then user1 on pi1 can directly write to the SDCard on pi2. All of my RPis can ALL write to shared directories on my ZyXel NAS using NFS shares mounted in /etc/fstab.

Re: transfer files between two RPi through CATe5 cable

Posted: Fri Jun 26, 2015 11:42 am
by Sorin_v2
Hi Dougie,

Thank you very much for your answer.

Regards,
Sorin