#!/bin/sh # avoiding "Device or resource busy" error as per https://forum.openwrt.org/viewtopic.php?pid=121485#p121485 # note that iwinfo takes care of this internally echo "Content-type: text/plain" echo "" DEV="${1:-wlan0}" ifconfig $DEV down iw dev $DEV interface add scan.$DEV type station ifconfig scan.$DEV up iwlist scan.$DEV scan | grep ESSID | cut -c 27- | tr -d '"' ifconfig scan.$DEV down iw dev scan.$DEV del ifconfig $DEV up