On Fri, Jul 18, 2025 at 9:34 AM Michael Barnes <barnmich...@gmail.com> wrote: > > On Thu, Jul 17, 2025 at 2:28 PM Russell Senior <russ...@personaltelco.net> > wrote: > > > On Wed, Jul 16, 2025 at 9:57 PM Michael Barnes <barnmich...@gmail.com> > > wrote: > > > > > > I have a script that is supposed to grab a weather feed and return the > > > current temperature. If grabs the file fine, but does not return the > > > temperature. > > > > > > Here is the line that fails: > > > > > > T=$(grep "<temp_f>" KEUG.xml |cut -c10- |cut -d '.' -f 1) > > > > Out of curiosity, why are you truncating the fractional part? > > > > > If you mean why am I using 88 instead of 88.0, I guess I did not explain my > use case. At the top of each hour the script runs and grabs the current > temperature. I have a folder of audio files from 0-110. When I get the > current temperature, the remainder of the script grabs the appropriate file > for announcements "The current temperature is 88 degrees." Hence, no need > for the fractional part. I certainly don't need the additional hundreds of > audio files to say "The current temperature is 88 point five degrees."
Ah, interesting. If it was me, I think I'd grab the complete number and round to the nearest integer, by adding 0.5 and then truncating the fractional part. I'd also note that another part of the XML file suggests checking the file at 15 minutes after the hour, as it apparently takes a while to process the measurement. If you ask at the top of the hour, the measurement you get is over an hour old. The two relevant elements are: <suggested_pickup>15 minutes after the hour</suggested_pickup> <suggested_pickup_period>60</suggested_pickup_period> -- Russell Senior russ...@personaltelco.net