Wednesday, September 18, 2013

Post 28: How I got my Pi to upload files to the Web

I first tried to "automate" FTP. But that command is oriented toward human (rather than programmed) input. That led me to CURL. I didn't bother to learn what the "c" stands for but the "url" part is obvious. So (in SSH) I typed--

  curl --help

And I got a "command not found"-type message. So then I blindly typed--

  sudo apt-get update # always a good idea


  sudo apt-get install curl

Ha! That worked too.

Then I set up my ".netrc" file. Which looks like this:

login your-user-name-at-yourplace
password your-pw-there

And make it secure (from ls -l .netrc)--

-rw-r----- 1 yourpi yourpi (file length) Sep  3 16:47 .netrc

Then you can enter a curl command like this--

curl --netrc -T file-to-send

And if that works, you can make a bash command file like this--

for i in your-list-of-files ...
 if [ -f $i ] ;
  if [ $i -nt uploadtime ] ; # only send files that are "new"
    curl --silent --netrc -T $i
    echo $i
date >uploadtime # save the time stamp

Then add it to your crontab tasks (to run as often as you need). You need to know about crontab!

Anyway, that's (sort of) how my Pi's data gets to

No comments:

Post a Comment