walolinux
walolinux

Reputation: 551

Qprocess arguments echo and piping

I am trying to launch a CEC command in my Raspberry Pi (Raspbian) under a QProcess.

if i execute in my shell this:

echo 'standby 0' | cec-client -s

it is working, but if i put it inside a Qprocess with this:

QProcess *proc = new QProcess;
proc->start("echo",{"'standby 0' | cec-client -s"});
proc->waitForFinished();

it is not executing as expecting. Otherwise in my Raspberry Pi is workig well. What am i doing wrong?

Upvotes: 1

Views: 655

Answers (1)

Simply Me
Simply Me

Reputation: 1587

The problem is you cannot run a system command with QProcess, but only a single process. So the workaround will be to pass your command as an argument to bash:

process.start("bash", QStringList() << "-c" << "echo 'standby 0' | cec-client -s");

Upvotes: 2

Related Questions