Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Set the SSID you want to reconnect to when found
- timstim=$(date -u)
- ssid="AD-INFRA-E1000"
- interface="wlan0"
- string=$(ifconfig $interface| grep "inet addr:")
- if [[ $string == *"inet addr:"* ]]; then
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"CONNECTED\"}]}"
- else
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"DISCONNECTED\"}]}"
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"SCANNING\"}]}"
- ssidlist=$(sudo iwlist $interface scan | grep ESSID)
- if [[ "$ssidlist" =~ "$ssid" ]]; then
- sudo ifup --force $interface
- sleep 10
- string=$(ifconfig $interface | grep "inet addr:")
- if [[ $string == *"inet addr:"* ]]; then
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"RECONNECTED\"}]}"
- else
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"UNKNOWN_ISSUE_RECONNECTING\"}]}"
- fi
- else
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"SSID_NOT_FOUND\"}]}"
- echo "{\"TIMSTIM\" : \""$timstim"\", \"WIFI\" : [{\"NETWORK_STATE\":\"DISCONNECTED\"}]}"
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement