-
Notifications
You must be signed in to change notification settings - Fork 0
/
net-select.sh
executable file
·32 lines (29 loc) · 1.16 KB
/
net-select.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#
# net-select.sh
#
# scans then searches for network name, selects network ESSID
# !!! requires user input !!!
#
# usage: ./net-select.sh "<network name query>"
# ex: ./net-select.sh "myNetwork"
#
shopt -s nocasematch # Set shell to ignore case
shopt -s extglob # For non-interactive shell.
readonly TARGETNET_QUERY=$1
readonly SPC=" "
TARGETNET_NAME=""
TARGETNET_SSID=""
sudo iwlist wlan0 scan | bash iwlist-format.sh | grep $TARGETNET_QUERY
echo -n "Choose target network (1 or 2, etc):"
read option
if [ "$option" == "1" ]; then
TARGETNET_NAME=$(sudo iwlist wlan0 scan | bash iwlist-format.sh | grep $TARGETNET_QUERY | sed -n 1p | awk "{print $2}")
TARGETNET_SSID=$(sudo iwlist wlan0 scan | bash iwlist-format.sh | grep $TARGETNET_QUERY | sed -n 1p | awk "{print $1}")
elif [ "$option" == "2" ]; then
TARGETNET_NAME=$(sudo iwlist wlan0 scan | bash iwlist-format.sh | grep $TARGETNET_QUERY | sed -n 2p | awk "{print $2}")
TARGETNET_SSID=$(sudo iwlist wlan0 scan | bash iwlist-format.sh | grep $TARGETNET_QUERY | sed -n 2p | awk "{print $1}")
else
echo "no fuego"
fi
echo $TARGETNET_NAME$(" ")$TARGETNET_SSID