I think I've got the hang of it.
I have been looking at this the wrong way all along. Python will never work when it comes to hacking pfSense because it's not its native language in the first place! However, unfortunately, the answer lies in PHP, the language I hated to learn and was hoping would never have to use again.
As it happens, PHP scripts can be run by passing it as an argument to /usr/local/bin/php, like any other interpreted language, like Python or Bash.
I have written a PHP script that utilises the underlying PHP backbone of pfSense and managed to get it to download a list of hosts from a text file shared on Google Drive and then reload the firewall rules:
[image: 1671296793438-24c0e2be-b77a-4527-944c-f5701876b98a-image.png]
I know pfSense is open software but I won't get into the details of how I managed to do that out of respect for the original coders that toiled and battled with PHP to get it all working. But of course, in true open source geek fashion, I will happily share it with interested parties.
By the way, is there a plan to rewrite everything in Python?