Itch
I can’t seem to find the time to do something substantial in the shack lately. If I’m there it is usually to tune around a bit, having some QSOs, but mostly lacking enough energy to build or repair something. It happens to us middle aged men, with a busy job, a family and kids to attend to. But I still have this itch to do something radio related and it needs to be scratched.
Luckily I have 10 minutes between the classes I teach and once in a while I get the urge to do something computer related. Now my computer skills are as good as my electronic skills: I don’t know much, but enough to get the job done. And when I get the job done the sense of achievement makes me happy for the rest of the week.
So for the last few days I have been spending those 10 minute breaks on automating the uploading of my logbook to my website. My coding skills are limited to Perl in combination with Linux shell scripts (plus PHP and HTML for the front-end). Luckily I can force myself to be structured, so I started with the sequence I had in mind:
1) retrieve the latest adif archive from CQRlog
2) unzip it and rename it to a standard name
3) read every QSO record into an array and filter out the ones you needs
4) extract the fields from a record and write it out to a HTML file
5) ftp the HTML file to the server
The great thing about Perl is that someone has probably done before what you want to do now. Retrieving the latest file from a directory is standard procedure, so a quick Google search provided some code I had to modify only slightly. Reading an adif file into an array has been done by Ted Pride as you can find here. Thanks Ted, now I only have to write out to a file, which I have done many times before. Easy peasy! Last step is to ftp it to the server, but Perl has an awkward procedure for that, so a bash script takes care of that.
It’s almost like playing with Lego. Take some blocks and build it into something you want. Sounds easy, but it can be frustrating, especially when you don’t understand the code from others, or when you make syntax mistakes. But Google is such a treasure trove of knowledge that you can usually find the answer to your problem very quickly. This time I got stumped by the fact that some code wouldn’t run straight from the command line. One 10 minute break was spend on searching and it turned out to be a new line problem, caused by some code having been written in a Windows environment. Dos2unix took care of that, so my Wednesday morning didn’t end in frustration.
So from now on every visit to the shack will end in running a single shell script which will update the logbook on my site, as well as all the QSO maps plus do a backup of some important files. Saves at least 10 minutes each time and a sore wrist from all those mouse clicks. You can see the result on pa2bx.nl –> Logbook.