Eric Bautista
Eric Bautista

Reputation: 413

QProcess does not work

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?

Upvotes: 2

Views: 723

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

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.

Upvotes: 2

Related Questions