I'm using a script to add a network to my wpa_supplicant.conf
and reload wpa_supplicant
to connect a new network. Something like this:
cat << EOF >> /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="$1"
psk="$2"
}
EOF
wpa_cli reconfigure
Then I simply copy the ssid from wpa_cli scan_results
and type the password to the script and I'm connected. Every now and then the command fails to connect. Even though it normally works I get CTRL-EVENT-NETWORK-NOT-FOUND
in wpa_cli
suggesting there is a typo in SSID.
Long story short the case was an invisible character, which get's hidden in console output of wpa_cli scan_results
, yet the character is there and thus the SSID don't match.
So what would be the best option for my script to get the right SSID no matter what crazy characters it contains? The output might look like this:
network={
ssid="Some Cool Network N@me "
psk="evencoolerpassword" # ^ this character is \x20
}