Timothy Jones on 23 Feb 2014 15:55:51 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Upload & Append Data to a Server


I'm working on a similar project. As I can see it now, you have two options that don't involve sftp:

A) No ssh access, server has php capability: You can create a PHP page that has a unique random name (so that strangers won't know it or couldn't guess it) and pass the updated data to that php script via URL query strings, e.g. use curl to have the pi call up the remote php script, say:

http://yourserver/random3j5j293528.php?temp=58.3?time=1532

the php script could then extract those numbers and append them to the file.

B) If you have ssh access, then you could set up keyless login and have the pi login and run a command that appends the new readings to the remote file, e.g.,

ssh user@yourserver -c 'sed 1d /home/usr/temp.dat; echo "58.3 1532" >> /home/user/temp.dat'

The first command, sed 1d filename, should delete the first line of the file (assuming that is the oldest line and you want your temperature data file to remain fixed in size so that new data is added to the last line and old data is removed from the first line) and the second line will append the new data at the end of the file.

The ssh option is the preferred option for security reasons, but the php option should only have a worst case scenario where somebody can fill your temperature file with bogus data if they somehow found that random url that you created.

> On Feb 23, 2014, at 6:02 PM, Casey Bralla <MailList@nerdworld.org> wrote:
> 
> There is probably a simple solution to my problem, but my Alzheimer's is 
> acting up, and I can't think of it.  Could somebody help?
> 
> 
> I'm gathering local weather data with my Raspberry Pi and want to upload it to 
> a web server, which will then run a python script to create some graphs and 
> format the data in a nice way for a web page.
> 
> The weather data is a simple flat file, with a new data point created every 
> minute.   I'd like to upload and append this data every minute to the web 
> server.
> 
> I've got SFTP access to both machines, and can run a python script to handle 
> the uploads.  What I'd really like is a sftp "append" option, but that doesn't 
> seem to exist.
> 
> The data file isn't huge,  so I could theoretically download it, append it, 
> then upload it again, but yech, what a cludge that would be!
> 
> Anybody got a good suggestion?
> -- 
> 
> Casey Bralla
> 
> Chief Nerd in Residence
> The NerdWorld Organisation
> 
> www.NerdWorld.org
> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug