Detect & connect to open (un-encrypted) networks

I have a two-radio “travel AP” that I bring with me from place to place. When there is Wifi but not wired access, I have to configure the “backhaul” radio to connect to the local AP.

My question: is there a script that will scan for open SSIDs, and connect to them one-by-one until it finds one that allows outside access? If not, I would appreciate any suggestions you might have to help me put one together myself. (I’m not new to scripting, just hoping someone might be able to point me in the right direction.)

I knew I had seen a static configuration somewhere that does (most of) what I need: in Butch Evans’ blog. I had neglected to tell the backhaul radio not to associate with the client radio on the same board…with predictable results! Live and learn.