vishnueevee
Posts: 2
Joined: Sun Apr 27, 2014 6:36 am

Sending data files from Raspberry Pi to PC automatically

Sun Apr 27, 2014 6:44 am

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.

User avatar
joan
Posts: 14193
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Sending data files from Raspberry Pi to PC automatically

Sun Apr 27, 2014 8:07 am

Google Linux copy files between machines. If you have a problem with the method you choose post back with what you have tried.

suicidal_orange
Posts: 217
Joined: Sun Mar 16, 2014 10:56 am

Re: Sending data files from Raspberry Pi to PC automatically

Sun Apr 27, 2014 8:11 am

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.

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

Re: Sending data files from Raspberry Pi to PC automatically

Sun Apr 27, 2014 8:12 am

http://www.raspberrypi.org/forums/viewt ... f=9&t=1989

Lots of this "current cost" stuff is done using MQTT.
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.

grats
Posts: 30
Joined: Fri Apr 25, 2014 6:51 am
Location: Colorado, USA

Re: Sending data files from Raspberry Pi to PC automatically

Sun Apr 27, 2014 9:40 am

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]

vishnueevee
Posts: 2
Joined: Sun Apr 27, 2014 6:36 am

Re: Sending data files from Raspberry Pi to PC automatically

Mon Apr 28, 2014 5:09 am

Sir,
Can you help me about the usage of SFTP and cron..?

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

Re: Sending data files from Raspberry Pi to PC automatically

Mon Apr 28, 2014 6:09 am

I think you'll find it's a whole bunch easier to use rsync with cron.
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.

eltrasimaco
Posts: 20
Joined: Fri Apr 25, 2014 10:50 am

Re: Sending data files from Raspberry Pi to PC automatically

Mon Apr 28, 2014 7:22 am

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

grats
Posts: 30
Joined: Fri Apr 25, 2014 6:51 am
Location: Colorado, USA

Re: Sending data files from Raspberry Pi to PC automatically

Mon Apr 28, 2014 6:30 pm

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

Return to “Advanced users”