:weather script - calling SED heads ! [longish]

David J Patrick davidjpatrick-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org
Thu Sep 30 18:32:37 UTC 2004


On Fri, 2004-09-17 at 10:33, Lennart Sorensen wrote:
> On Fri, Sep 17, 2004 at 12:33:13AM -0400, David J Patrick wrote:
> > Hey Lennart! With a few clues dropped, I got it working !
> > Now (not to be pickey) This is current conditions, right ? Can the same
> > service be induced to give out a forcast ? Can I tell it to skip the
> > farenheit ? Where would I turn to answer some of these daft questions
> > myself ? 
> 
> Well where it has the foreach at the end, you could change it to just
> print the keys you want rather than all of them.

Not knowing anything much about perl and/or Weather::Underground, I have
undertaken to boil down the result of the above weather.pl script, and
the result of something called "sunwait", using ol' SED. Now, I admit
that I've barely got a handle on that "stream editor", so I'm posting my
sed problem, before wasting a week trying every concievable combination.
===================
the output of weather.pl (today) gives me 

MATCH:
        celsius = 18
        pressure = 30.06 in / 1018 hPa 
        temperature_celsius = 18
        place = Toronto
        windchill_celsius = 
        wind = 9 mph 15 km/h from the SSW 
        fahrenheit = 64
        updated = 1:00 PM EDT on September 30, 2004
        windchill_fahrenheit = 
        conditions = Clear
        temperature_fahrenheit = 64
        humidity = 59
====================
and the output of sunwait (using "sunwait sun -p 43.40N 79.24W") is

Using location:             43.400000N, 79.240000W
Date:                       30 Sep 2004 
Local time:                 13:46 
Day length:                 11:45 hours
With civil twilight         12:39 hours
With nautical twilight      13:45 hours
With astronomical twilight  14:52 hours
Length of twilight:  civil   0:26 hours
                  nautical   1:00 hours
              astronomical   1:33 hours
Current specified time zone: EDT (-4 from UTC) 
Sun transits meridian 1306 EDT
                   Sun rises 0715 EDT, sets 1857 EDT
       Civil twilight starts 0646 EDT, ends 1926 EDT
    Nautical twilight starts 0613 EDT, ends 1959 EDT
Astronomical twilight starts 0540 EDT, ends 2032 EDT

(although all I really want is the line containing "Sun rises")
======================
The desired "conditions.sc" block would be something like:

Toronto @ 1:00 PM EDT
celsius = 18
conditions = Clear
humidity = 59
pressure = 30.06 in / 1018 hPa 
wind = 9 mph 15 km/h from the SSW 
Sun rises 0715 EDT, sets 1857 EDT
===========================
Here is the pertainant block of my "callsheet" script.

#### atmospheric conditions ####
# clsht -w [location] 
# ^^^ set program and user defaults
# ??? how can I ensure program completion, even if this module (or ANY
part) fails ???
weather.pl > weather.sc
#SED 
# ^^^ remove lines ending in "="
#SED 
# ^^^ remove lines containing "MATCH:"
#SED 
# ^^^ remove lines containing "farenheit"
#SED 
# ^^^ remove lines containing "temperature_celsius =" (redundant)
#SED 
# ^^^ find line containing "place =", grab corresponting value to buffer
#SED 
# ^^^ remove line containing "place ="
#SED 
# ^^^ on line containg "updated =" replace "updated" with %place =%,
truncate line from "on" to end
#SED
# ^^^ remove leading and trailing blank spaces
# cat to conditions.sc
# sort conditions.sc alphabetically

# set user default lat & long 
sunwait sun -p $LATLONG > astro.sc
#SED /Sun rises//d
# ^^^ remove lines not containing "Sun rises"
#SED /$ //d
# ^^^ remove leading spaces
# >> conditions.sc
==========================
Any clues would be appreciated. 
Am I asking you to write my script for me ?
Heck no !      ..would you mind ?? ;-)
This is all going to get wrapped up and posted to Sourceforge, where the
whole weird ball o wax will be available to those with a similar bent.
thanks,
djp










--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list