:weather script - calling SED heads ! [longish]

David J Patrick davidjpatrick-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org
Sat Oct 2 18:29:33 UTC 2004


On Sat, 2004-10-02 at 01:39, William Park wrote:

> 
> It's not so much typing error, but scripting error.
> 
>     while ...; do
> 	case ... in
> 	    ...
> 	esac
> 	echo "$place @ ..." 
>     done
> 
> Here 'echo' will run for every line.  'echo' should be placed outside
> the while-loop, something like
> 
>     ( while ... ; do
> 	...
>       done
>       echo "$place @ ..."
>     )
This makes sense With the repeated "Toronto @" jazz. 
What about the brackets in the above example ? Should I add a set ?
And what about "< weather.sc | sort" ? With it now parked outside the
do/done set nothing happens. Obvious again, isn't it ? sigh.. 
I'll try stuff, but right now it doesn't work, and it's shaped like
this;

weather.pl > weather.sc
  while read a eq b; do
        case $a in 
            celsius|conditions|humidity|pressure|wind) echo "$a = $b" ;;
            place) place=$b ;;
            updated) updated=$b ;;
        esac
    done < weather.sc | sort
 echo "$place @ ${updated% on *}"

> 
> This would be obvious if you actually tried to run the code. :-/

Alright smart-e-pantz, I /did/ run the code.
It should have been obvious, and is in retrospect, but I have little
experience crafting for/ next loops. From today, when I see unwanted out
repeated so, I will know to look in the loop for the offending error. 

I appreciate your methods, both in programming and in forcing me to
consider the workings of the elements. Yeah, I'm learning. I haven't got
it working right, but I'm learning. ;-) I fear I'll never actually be
good at this, but I's fun taking baby steps.

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