Solved Weird behavior of QProcess and multiple qoutes
-
@Christian-Ehrlicher
I have run it on the command line, it is no problem. -
@Guanhong Please show how you run it on the command line
-
@Guanhong said in Weird behavior of QProcess and multiple qoutes:
<
wpa_cli -i wlan0 set_network 1 ssid '"hima24g"'
I run it on an Ubuntu console, and it can run successfully -
@Guanhong said in Weird behavior of QProcess and multiple qoutes:
wpa_cli -i wlan0 set_network 1 ssid '"hima24g"'
wpa_cli -i wlan0 set_network 1 ssid hima24g
should work just as good
-
set_network 1
is not
"set_network" << "0"
-
wpa_cli -i wlan0 set_network 1 ssid hima24g
without quotes, it does not work on my console.set_network 1 or set_network 0 does not matter.
It depends. -
@Guanhong So, did you try to print out https://doc.qt.io/qt-5/qprocess.html#readAllStandardError ?
-
Looks like wpa_cli really needs additional double quotes... strange and weird program (see google for a lot of confusion due to this behavior).
So it must bearguments << "-i" << "wlan0" << "set_network" << "0"<< "ssid" << "\"" + strSSID + "\"";
-
@Christian-Ehrlicher
this command includes not only double quotes but also single quotes outside. Can QProcess handle it? -
The outer quotes are only needed so the inner ones are not removed by the shell.
-
@Christian-Ehrlicher
I don't think so. both quotes are necessary, without either, the command doesn't work on command line. -
@Guanhong
Do you understand that, certainly quote-wise, what you type into a shell/command-line is not the same as what you would put into theQStringList
for the arguments toQProcess::start()
?Meanwhile if you helped us by using the forum's Code toolbutton around what you are entering on the command-line it would be a lot easier to read/understand.
-
@Guanhong said in Weird behavior of QProcess and multiple qoutes:
I don't think so. both quotes are necessary, without either, the command doesn't work on command line.
I'm giving up.... don't know how often I must explain that your shell/command line removes the outer quotes...
-
@Christian-Ehrlicher
thank you very much ,
arguments << "-i" << "wlan0" << "set_network" << "0"<< "ssid" << """ + strSSID + """;
works.sorry for my poor understanding.