Utilities Are Good For You
Every week, I participate in Winlink Wednesday. I do my check-ins with pat. Once a month, they as for a weather snapshot to go with the check-in. This isn’t particularly onerous, but I have top open my weather widget and then type out the weather. That seems like the kind of thing one could automate, right?
Enter wttr.in.
With a simple curl command, you can pull your local weather from the internet in a billion different formats. But the one thing it won’t do is put the wind’s direction in simple text. No. It give arrows. And that? That’s not great for a copy/paste. It’s also not great for me because I have to think about what the arrow is trying to tell me. So what to do?
20 Minute Of Free Time
I had 20 minutes. I started to poke at making a bash script that would grab the weather, look for the arrow, parse it out and make it text. Then dump it to the console. Easy enough!
curl -s 'wttr.in/?format=%25T%20%25C%20%25w%20%25t&u' \
| sed 's/↖/NW/g; s/↗/NE/g; s/↙/SW/g; s/↘/SE/g; s/←/W/g; s/→/E/g; s/↑/N/g; s/↓/S/g'
The arrows in the code block above are rendering in an unexpected way and I don’t care to wrestle with WordPress right now.
Is this the most elegant solution? Probably not. Does it work? Yes! That’s the definition of all shell scripts, right? If it works, you run it. And probably never change it.
But That Only Took 5 Minutes
I had more minutes left! What to do?!
Well, first, I made a silly parser to grab the most recent bluesky post from the local parks district because they use that to share when the mountain bike trails are opened or closed. I got crazy with that and used emojis and other nonsense. I’m not posting that here because if you don’t ride mountain bikes at that specific park, it’s not useful at all. And I’m not convinced it’s useful to me except when pared with a script I’ll run once or twice a day.
That Was Dumb…But Still 10 Minutes To Kill!
So what if – hear me out – I had the band conditions in there somewhere too? What if I grabbed stuff from Ham QSL and dumped that to the console too? What if I even took a really poor stab at listing band conditions? Well, with 10 minutes and an open text editor, this is what I built:
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📻 BAND CONDITIONS..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
curl -s https://www.hamqsl.com/solarxml.php \
| awk '
/<kp>/ {gsub(/.*<kp>|<\/kp>.*/, ""); kp=$0+0}
/<aindex>/ {gsub(/.*<aindex>|<\/aindex>.*/, ""); ap=$0+0}
/<solarflux>/ {gsub(/.*<solarflux>|<\/solarflux>.*/, ""); sfi=$0+0}
END {
cond=(kp<3?"Quiet":(kp<5?"Unsettled":"Storm"));
band80 = (kp>=6?"Poor":(kp>=5?"Fair":"Good"));
band40 = (kp>=6?"Poor":(kp>=5?"Fair":"Good"));
band20 = (kp>=6?"Poor":(kp>=4?"Fair":"Good"));
band15 = (kp>=5?"Poor":(kp>=3?"Fair":(kp==4?"Fair":"Good")));
band10 = (kp>=5?"Poor":(kp>=3?"Poor":"Fair"));
printf "Kp:%.1f Ap:%d SFI:%d %s | ", kp, ap, sfi, cond;
printf "80m:%s 40m:%s 20m:%s 15m:%s 10m:%s\n",
band80, band40, band20, band15, band10;
}'
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
I was having all kinds of trouble with getting the XML parsed and I wasn’t willing to use a real language so…awk to the rescue, I guess? I could do this in a much cleaner way and dumping it to the internet like this is probably irresponsible. But KC1SRI asked nicely on Mastodon, so here it is.
Final
That’s it. This is what happens when a dude has 20 minutes and an open terminal and a couple of really half baked ideas. This thing will probably turn into a big, long script that dumps out calendar stuff too just because I can.
73 and thanks for reading!
![]()