LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-29-2007, 02:05 PM   #1
seanferd
LQ Newbie
 
Registered: Feb 2006
Distribution: Debian Wheezy
Posts: 13

Rep: Reputation: 0
Programming help


Hi,

I have a weather station at home that's collecting data into a text file. I'm basically wondering how to take the format it's giving me, and put it into an HTML webpage. The text file looks like this:

[weather_tendency]
comment_1 = "-1=not valid, 0=no change of air pressure"
comment_2 = " 1=air pressure rising, 2=air pressure falling"
number = 0

[indoor_temperature]
deg_C = "24.2"
deg_F = "75.5"

[outdoor_temperature]
deg_C = "22.3"
deg_F = "72.1"

I don't even know if that's a language. I'm hoping it's XML since you can embed it into HTML, but I don't think it is. I'm running Debian Etch with PHP 5.1 and Apache2, perhaps there is a way to parse this data out the "hard way"?

Thanks for any help!
 
Old 05-29-2007, 04:00 PM   #2
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
A simple shell script can do this for you.

Code:
sed -n "/indoor_temperature/,3 p" <file>
The result would be below:
Code:
[indoor_temperature]
deg_C = "24.2"
deg_F = "75.5"
From then on, you can use awk/sed to grab only the temperature readings and save that to a variable. Then you can format the html to whatever you want. And, do the same thing with "outdoor_temperature".

-twantrd
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Top Down programming & Bottom up programming minil Programming 1 06-17-2005 02:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration