title: qt run shell commands via qprocess
body: <p>I am developing a small QT application to interact with the terminal, to send commands to the terminal and to read back information printed out.</p>
  
  <p>Example: get output of all processes using <code>ps -aux</code></p>
  
  <p><strong>PROBLEM</strong></p>
  
  <p>I am able to write information out to the terminal but I dont think it is in the system scope, actual example:</p>
  
  <p><strong>Command passed to shell interpreter</strong> : <code>"echo "pre"; ps -aux; echo "post"</code></p>
  
  <p><em>edit from comment:</em> </p>
  
  <p>I need to send specific complete commands, I am not looking for shortened or alternative commands, I require a method of sending a command like this : <code>ps -aux | grep chrome | tr -s " " | cut -d " " -f 2</code> and reading its output. This example is getting all pid's of all running chrome processes</p>
  
  <p><strong>Interpreters attempted</strong> : </p>
  
  <ul>
  <li><code>sh</code></li>
  <li><code>/bin/bash</code></li>
  </ul>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>QProcess *proc_ovpn = new QProcess(this);
  proc_ovpn-&gt;waitForFinished();
  proc_ovpn-&gt;start("sh",QStringList() &lt;&lt; "-c" &lt;&lt; "echo \"pre\";ps -aux; echo \"post\"");
  proc_ovpn-&gt;setProcessChannelMode(QProcess::MergedChannels);
  QString str(proc_ovpn-&gt;readAllStandardOutput());
  return str;                             &lt;&lt;&lt; ======= //breakpoint here
  </code></pre>
  
  <p><strong>Debug information:</strong></p>
  
  <p>When breakpoint is reached, debug information as follows:</p>
  
  <pre><code>Locals      
      str ""  QString
      this    @0x555555ad7be0 Interface
  Inspector       
  Expressions     
  Return Value        
  Tooltip     
      10000000    10000000    int
  </code></pre>
  
  <p>It was suggested to run shell code using this method above from a post on SO, could not find it again.</p>
  
  <p>I am at a loss, I do not understand why running these commands to not interact directly with the system (and its information),</p>
  
  <p>Any advice?</p>