iw list doesn't effectively scan for devices nearby as it doesn't run for much longer than a couple seconds. So I used zsh's repeat command to run it 30 times before displaying output.
I don't want to be put into monitor mode every time I want to get an updated list of nearby devices via wlan so I made this:
Code:
#!/bin/zsh
echo ""
echo "### zsh required! ###"
echo ""
echo "Turning Power Management off..."
ifconfig wlan0 down
sleep 1
iwconfig wlan0 power off
sleep 1
ifconfig wlan0 up
sleep 1
echo "-------------------"
echo " Power Managment "
echo " is now OFF "
echo "-------------------"
sleep 3
echo "==================================="
echo "Here are your all your settings"
echo "==================================="
iw reg get
echo
echo "==================================="
iwconfig wlan0
echo "==================================="
sleep 3
upstream=br0
phy=wlan0
conf=/etc/mana-toolkit/hostapd-karma-all.conf
hostapd=/usr/lib/mana-toolkit/hostapd
sleep 1
echo "Setting wlan0 channel to 11"
echo "==================================="
sleep 3
iwconfig wlan0 channel 11
echo -e -n '\033[?25l'
repeat 30 iwlist wlan0 scan | \
echo -ne 'Scanning wlan0... (Scanning For up to 30 Seconds)\r'
iwlist wlan0 scan | grep 'Address:\|ESSID:\|Authentication\|Suites\|Mode\|Pairwise\|Ciphers\|Cipher\|Group\|Groups\\|802.11i' > aplog.txt
sleep 0.5
echo -ne 'Saving Nearby Access Details: ##### (33%)\r'
sleep 0.5
echo -ne 'Saving Nearby Access Details: ############# (66%)\r'
sleep 0.5
echo -ne 'Saving Nearby Access Details: ####################### (100%)\r'
sleep 1
echo -e '#### Saved in File aplog.txt ####'
echo "Displaying Results..."
sleep 5
iwlist wlan0 scan | grep --color 'Address:\|ESSID:\|Authentication\|Suites\|Mode\|Pairwise\|Ciphers\|Cipher\|Group\|Groups\\|802.11i'
You may ask why not use wicd or network-manager or even wicd-curses?
Because I use a single board computer the has no display connected and only control it with ssh.
why not wicd-cli or wicd-curses?
wicd-cli doesnt show all information I need and wicd-curses has no log output function.
Even if it did I don't want a network manager interfering with mana-toolkit and have to worry about conflictions.