Question
I have the following code:
const char* argument = string1.c_str();
QString arg(argument);
QProcess *proc = new QProcess(this);
proc->start(arg);
The value of string1 is:
ps -ef | grep "./scriptTest" | grep -v grep | awk '{print $2}' | xargs kill
The problem is that the QProcess doesn't execute the command. If I copy and paste the value of string1 in the console, the command is executed successfully.
Do you guys have any suggestion?
Solution
Either invoke a shell in order to run the shell pipeline, or only run ps
and do the rest of the processing in your program.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow