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
And
sudo apt-get install curl
Ha! That worked too.
Then I set up my ".netrc" file. Which looks like this:
machine ftp.yourplace.com
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 ftp://ftp.yourplace.com/some-folder/
And if that works, you can make a bash command file like this--
#!/bin/bash
for i in your-list-of-files ...
do
if [ -f $i ] ;
then
if [ $i -nt uploadtime ] ; # only send files that are "new"
then
curl --silent --netrc -T $i ftp://ftp.yourplace.com/.../
echo $i
fi
fi
done
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 http://raspi-online.info/
No comments:
Post a Comment