Sorin_v2
Posts: 7
Joined: Fri May 08, 2015 3:02 pm

transfer files between two RPi through CATe5 cable

Thu Jun 25, 2015 4:26 pm

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

User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: transfer files between two RPi through CATe5 cable

Thu Jun 25, 2015 4:51 pm

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.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Sorin_v2
Posts: 7
Joined: Fri May 08, 2015 3:02 pm

Re: transfer files between two RPi through CATe5 cable

Fri Jun 26, 2015 11:42 am

Hi Dougie,

Thank you very much for your answer.

Regards,
Sorin

Return to “Beginners”