Using shell scripts to automate CTY file updates in Fldigi and WSJT-X

If you’re a user of Fldigi or WSJT-X as well as some contest software (particularly on Windows), you may be already familiar with AD1C’s outstanding Country Files. These files contain unusual or special callsigns that may be short term in nature, used only during contests, or have an unusual format that doesn’t match to DXCC conventions. AD1C tracks these and provides updates in the form of the CTY files, such as the CTY.dat file used by Fldigi and WSJT-X.

Additionally, Fldigi can make use of the LoTW users listing from HB9BZA as well as the eQSL users listing provided by eQSL.

While these files can be downloaded and updated manually, there is an easy way to automate these updates on a daily/weekly/monthly basis. Best of all, it is built right into OS X at the system level. For those not afraid to go to the command line, all it takes is a simple script to automate these downloads and have them run without user intervention. (see warnings at the bottom of the post)

While I won’t paste the entire script here, I will include the instructions for you to print out or to follow along.

  • For starters, download the sample script and save it in your Downloads folder
  • Open Terminal and type: cd Downloads
  • Type in Terminal: sudo nano 120.ctyfilescript
  • Enter your password when prompted
  • Scroll down through the text using the arrow keys and look for the two lines containing “USERNAME” in all caps. Replace both occurences with your OS X user name.
  • If you do not use WSJT-X, place a hash (#) at the beginning of each of the two blank lines following the WSTJ-X tags
  • If you do not use Fldigi, place a hash (#) at the beginning of each of the four blank lines following the Fldigi tags
  • Hit CTRL+X (Not CMD+X) to exit the nano editor, answering “Y” to save your changes
  • Type in Terminal: sudo cp 120.ctyfilescript /etc/periodic/xxxxx/ where xxxxx equals either daily (for daily updates), weekly (for weekly updates) or monthly (for monthly updates). Make sure you include the trailing /
  • Type in Terminal: cd /etc/periodic/xxxxx where xxxxx equals either daily, weekly or monthly (whichever you selected in the previous step)
  • Type in Terminal: sudo chmod +x 120.ctyfilescript (this makes the script executable)
  • Your script should now be ready to run. You can test it by entering in Terminal: sudo ./120.ctyfilescript The script should run for a several seconds (depending upon internet connection speed) and then terminate. You can verify new files by opening the Fldigi configuration folder and check the dates on the three files updated: AGMemberList.txt, lotw1.txt, and cty.dat. If the files have not been updated, then you can check the system logs for clues on the error (usually a mistyped username or an accidentally deleted or added / or space)

NOW, FOR SOME NOTES AND CAVEATS:

HERE IS YOUR FAIR WARNING. YOU CAN SERIOUSLY MESS UP YOUR SYSTEM IF YOU GO INTO THESE FOLDERS AND START CHANGING THE CONTENTS OR THE SETTINGS. I STRONGLY ADVISE YOU TO NOT MESS WITH ANY OTHER FILES. ALTHOUGH I HAVE RUN WITH THIS CONFIGURATION FOR MORE THAN 4 YEARS WITH NO ISSUES, I DO NOT GUARANTEE THAT YOU WON’T RUN INTO ISSUES. FINALLY, IF YOU ARE UNCOMFORTABLE WORKING AT THE COMMAND LINE, DO SO WITH EXTREME CAUTION AND ONLY AFTER READING AND UNDERSTANDING EACH STEP OF THESE INSTRUCTIONS.


I have noticed that if you download a corrupted cty.dat file, usually due to misediting the script, you can render WSJT-X unable to run. In those cases, fix the error in the script, then go to Terminal and type the following:

cd /Users/USERNAME/Library/Application\ Support/WSJT-X/

and remove the existing cty.dat file

rm cty.dat

Try running the script again to place a correct copy of the file into the folder.


The script function is provided by the CURL tool, used to transfer data to or from a server using a variety of protocols and without user intervention. The logical function of the script is as follows:

  • Change directory to the Fldigi configuration directory
  • Download the latest LoTW users list using CURL
  • Download the latest eQSL AG users list using CURL
  • Download the latest cty.dat file using CURL
  • Change directory to the WSJT-X files directory
  • Download the latest cty.dat file using CURL

The script then terminates


This script is provided free-of-charge. You are welcome to modify it, adapt it, redistribute it, or use it however you see fit. It is provided without warranty or guarantee.