Posts: 1
Joined: Wed Oct 11, 2017 5:26 pm

Trying to figure out how to update HTML file

Mon Apr 16, 2018 2:33 am

I am new to Raspberry Pi. I am trying to find a way to save a certain part of a terminal output to a .html file to update a website.

Here's how the process would go.

User: Runs command

Pi: Outputs
"lorem ipsum dolor set amet 456
a1b2c3a1b2c3 temp=27.61"

Pi: Saves "27.61" to index.html

Is this possible, if so how?
If not, how can we make it possible? ;)

Posts: 4825
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Trying to figure this out.

Mon Apr 16, 2018 10:30 am

Yes its possible to write the temp to a file.

but without knowing a lot more about your existing program and what else you need in your html file I can only give you a general example.

Code: Select all

import time

adc =  " The time is "

reporttime = (time.strftime("%H:%M:%S"))

result = open("/home/pi/index.html","w")
result.write(adc + reporttime + "\n")

Remember we want information no help
The use of crystal balls & mind reading is not supported

Posts: 174
Joined: Fri Feb 09, 2018 3:45 am
Location: Minneapolis, MN USA
Contact: Website Skype

Re: Trying to figure out how to update HTML file

Mon Apr 16, 2018 1:33 pm

Code: Select all

<command> | tail -n 1 | cut -d = -f 2 > index.html
If that's not enough, you need to be more detail in what you want than:
bentronix wrote:Pi: Saves "27.61" to index.html

Return to “Beginners”