Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top