Thanks for that info pcmanbob.
On my headless Pi Zero W running Raspian Stretch, I tweaked it a bit in a shell script to:
Code: Select all
sudo ifconfig wlan0 down
sudo ifconfig wlan0 up
The 30 second delay lets me turn on the WiFi hotspot on my laptop that I want the RPi to reconnect to.