How not to do it:

essid="test"
key="blah"
cat << END
network={
    ssid="$essid"
    key_mgmt=WPA-PSK
    psk="$key"
}
END > /tmp/bar.txt

How to do it as sudo:

sudo sh -c "cat<> /etc/wpa_supplicant/wpa_supplicant.conf

network={
    ssid="$essid"
    key_mgmt=WPA-PSK
    psk="$key"
}
END"

Thanks #bash on Freenode :)

Feedback

Powered by Vanilla PHP feedback form