1

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
}

1 Answer 1

1

I could use the iw command to figure out such a case, as it escapes the unpritable characters like so:

# iw dev wlp3s0 scan | grep SSID
SSID: Some Cool Network N@me\x20

Then I vim /etc/wpa_supplicant/wpa_supplicant.conf and add the invisible character by typing <C-v>x20 at the right position.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .