Page 1 of 1

Sending data files from Raspberry Pi to PC automatically

Posted: Sun Apr 27, 2014 6:44 am
by vishnueevee
I am using my raspberry pi to communicate with an energy metering IC. I am able to successfully communicate with the IC and receive the data from the IC.
I store these data in the form of a text file. Now, I need to send the data files to my PC automatically say, by running a program.
Suggest me some methods or program codes to do this.

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Sun Apr 27, 2014 8:07 am
by joan
Google Linux copy files between machines. If you have a problem with the method you choose post back with what you have tried.

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Sun Apr 27, 2014 8:11 am
by suicidal_orange
The easiest way would be to save the files to a shared folder over the network - either a Windows (assumed) share mounted on the Pi or set up samba on the Pi and map the network share as a drive on the Windows box.

If you only want it to happen every half hour (or other time interval) look into cron which is the Linux equivalent of task scheduler.

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Sun Apr 27, 2014 8:12 am
by DougieLawson
http://www.raspberrypi.org/forums/viewt ... f=9&t=1989

Lots of this "current cost" stuff is done using MQTT.

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Sun Apr 27, 2014 9:40 am
by grats
Well, considering the raspbian operating system comes with SSH... you automatically have SFTP, use that?
That's what I use, it's pretty straight forward to send files to and from.. no reason to get all fancy with samba stuff (also that's just adding more memory usage)
can do a script to auto send it, or a cron job.. or a cron job triggering a script that sends it. Doesn't really matter


/edit

considering you're using a text file, I'd just install ssmtp
https://wiki.archlinux.org/index.php/SSMTP
http://tombuntu.com/index.php/2008/10/2 ... ith-ssmtp/


have a header for your text files as seen at the bottom:
To: [email protected]
From: [email protected]
Subject: whatever

put your data here that you want to send



or what I do in some cases:

echo -e "to: [email protected] \nsubject: subject \n"| (cat - && uuencode /path/ IC.txt) | ssmtp [email protected]

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Mon Apr 28, 2014 5:09 am
by vishnueevee
Sir,
Can you help me about the usage of SFTP and cron..?

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Mon Apr 28, 2014 6:09 am
by DougieLawson
I think you'll find it's a whole bunch easier to use rsync with cron.

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Mon Apr 28, 2014 7:22 am
by eltrasimaco
crontab -l >/tmp/erase.me
vi /tmp/erase.me # here you add a line with the entry u like, something like "0 0 * * * scp filename [email protected]:filename" (without quotes, copy daily at midnight local file "filename" to "remote" host)
crontab /tmp/erase.me
# restart cron and youre done
# instead of this u can use crontab -e
# as said, maybe rsync is easier
# you MUST remove the password auth in SCP setting ssh keys in both nodes, look here http://unix.stackexchange.com/questions ... sword-less

Re: Sending data files from Raspberry Pi to PC automatically

Posted: Mon Apr 28, 2014 6:30 pm
by grats
sshpass -p "password" scp -v /home/pi/motion.log [email protected]:/home/storage/

change where needed just copied and pasted and changed the password lol

one line command to pass password with scp and transfer the file

but the ssmtp email is also just a 1 line and sends whatever file you want

rsync is easy too