Scanning all available WIFI SSIDs


does anyone have any pointers on how I would create either a sketch or a script on the linino side to get all available SSIDs to then proceed to connect to one of the open ones?

Fundamentally I would like the Yun to connect to any open Wi-Fi it can find in range.