0

i am using QProcess in order to connect to a wifi network. But when i try the code with 6 arguments, it fails, no output is returned.

If i execute the command in the terminal, it works out of the box: nmcli dev wifi con "myssid" password "myssidpassword"

QStringList arguments{"dev", "wifi", "con", "\"myssid\"", "password", "\"myssidpassword\""};QProcess *process = new QProcess;
process->start("nmcli", arguments);
process->waitForFinished();
return process->readAll();

What am i doing wrong? Thanks.

PD: if i execute other nmcli with 2 arguments, it works.

walolinux
  • 531
  • 1
  • 6
  • 20
  • Why the double quotes around the ssid and the password? – peppe Jan 25 '15 at 19:13
  • Cause some wifi networks has a space in the ssid and if i need to connect to one of them, if i dont put the quotes, the command will interpret the second word of the ssid as a nmcli parameter. – walolinux Jan 25 '15 at 19:15
  • Which is absolutely valid when it comes to shell quoting, but this is C++! – peppe Jan 25 '15 at 21:57
  • I've tried without quotes but QBytearray in process->readAll(); returns "" – walolinux Jan 26 '15 at 07:16

1 Answers1

0

OK, qprocess was launching standard error, so i need to capture the string with:

qDebug()<< " Standart Error :"<< process->readAllStandardError();

walolinux
  • 531
  • 1
  • 6
  • 20