Command working in terminal, but not via QProcess

前端 未结 3 1961
一整个雨季
一整个雨季 2020-11-30 07:48
ifconfig | grep \'inet\'

is working when executed via terminal. But not via QProcess

My sample code is

QProcess p1;
p1.star         


        
3条回答
  •  天涯浪人
    2020-11-30 08:07

    The QProcess object does not automatically give you full blown shell syntax: you can not use pipes. Use a shell for this:

    p1.start("/bin/sh -c \"ifconfig | grep inet\"");
    

提交回复
热议问题