arunkumaraymuo
28th October 2015, 12:04
I am trying to read the output of a linux command using QProcess but its not given the correct output.
QProcess process;
process.start("iwconfig 2>&1 | grep ESSID");
process.waitForFinished();
usleep(1000);
QString output(process.readAllStandardOutput());
qDebug()<<output;
QString err(process.readAllStandardError());
qDebug()<<err;
In this code the qDebug()<<output; prints "" and
qDebug()<<err; prints "iwconfig: unknown command "|"
"
When I run this same command "iwconfig 2>&1 | grep ESSID" in terminal window its shown
wlan0 IEEE 802.11bgn ESSID:"Arun Kumar" Nickname:"<WIFI@REALTEK>"
Why my program printing "iwconfig: unknown command "|"", what is the error in my code and how I can correct this in my code?
QProcess process;
process.start("iwconfig 2>&1 | grep ESSID");
process.waitForFinished();
usleep(1000);
QString output(process.readAllStandardOutput());
qDebug()<<output;
QString err(process.readAllStandardError());
qDebug()<<err;
In this code the qDebug()<<output; prints "" and
qDebug()<<err; prints "iwconfig: unknown command "|"
"
When I run this same command "iwconfig 2>&1 | grep ESSID" in terminal window its shown
wlan0 IEEE 802.11bgn ESSID:"Arun Kumar" Nickname:"<WIFI@REALTEK>"
Why my program printing "iwconfig: unknown command "|"", what is the error in my code and how I can correct this in my code?