Cannot connect to wifi name has character represented
-
i am trying to connect wifi by using nmcli. When wifi name has character represented then i got error:
Syntax error: Unterminated quoted string
here is my code:void WifiThread::connectWifi(QString strName, QString strPassword) { QString strTmp = QString("nmcli --wait 20 device wifi connect \"%1\" password \"%2\" 2>&1").arg(strName, strPassword); QByteArray ba = strTmp.toUtf8(); const char *pCommand = ba.data(); system(pCommand); }
thank you so much for your help.
-
all characters in this link: https://www.austincc.edu/rickster/COSC1320/handouts/escchar.htm
-
all characters in this link: https://www.austincc.edu/rickster/COSC1320/handouts/escchar.htm
@hooanghiep You need to escape such characters, like
nmcli --wait 20 device wifi connect \"abcd\\\"efg\" password ...
First 2 backslashes are there to put a backslash into your string, third one is to escape " in C++.
-
@hooanghiep You need to escape such characters, like
nmcli --wait 20 device wifi connect \"abcd\\\"efg\" password ...
First 2 backslashes are there to put a backslash into your string, third one is to escape " in C++.
@jsulm how about these characters: "\", " ' ", "?"
thanks for your answer. :) -
@jsulm how about these characters: "\", " ' ", "?"
thanks for your answer. :)@hooanghiep said in Cannot connect to wifi name has character represented:
how about these characters
It's same for all characters which needs to be escaped in a shell.