title: QProcess fails to execute a terminal line command via QPushButton
body: <p>I am trying to execute a command line using <code>QProcess</code> as soon as I push a <code>QPushButton</code> on my gui.
  <strong>The problem</strong> I have is that the <code>.sh</code> executable file is never executed.</p>
  
  <p>The script I am trying to execute is very simple and reported below:</p>
  
  <pre><code>#!/bin/bash
  echo "try one two three"
  rostopic echo -b LaserScan_PointCloud2_test.bag -p /scan &gt; laserScan_test_1.csv
  </code></pre>
  
  <p>Below the function that activate the button:</p>
  
  <p><strong>filterpcdinterface.h</strong></p>
  
  <pre><code>private slots:
      void on_executeScriptBtn_clicked();
  private:
      QProcess *executeBash;
  </code></pre>
  
  <p><strong>filterpcdinterface.cpp</strong></p>
  
  <pre><code>FilterPCDInterface::FilterPCDInterface(QNode *node, QWidget *parent) :
      qnode(node), 
      QMainWindow(parent),
      ui(new Ui::FilterPCDInterface)
  {
      ui-&gt;setupUi(this);
      executeBash = new QProcess;
      executeBash-&gt;setProcessChannelMode(QProcess::MergedChannels);
      connect(executeBash, &amp;QProcess::readyReadStandardOutput, [this] {
      qDebug() &lt;&lt; "This is the output from the process: ";
        on_executeScriptBtn_clicked();
      });
  }
  
  
  void FilterPCDInterface::on_executeScriptBtn_clicked()
  {
    executeBash-&gt;waitForFinished();
    QString script("/home/emanuele/Desktop/bags/test.sh");
    executeBash-&gt;start("sh",QStringList() &lt;&lt; script);
  
    if(!executeBash-&gt;waitForStarted()) //default wait time 30 sec
        qWarning() &lt;&lt; " cannot start process ";
  
    int waitTime = 60000 ; //60 sec
    if (!executeBash-&gt;waitForFinished(waitTime))
             qWarning() &lt;&lt; "timeout .. ";
  
    executeBash-&gt;setProcessChannelMode(QProcess::MergedChannels);
    QString str(executeBash-&gt;readAllStandardOutput());
  }
  </code></pre>
  
  <p>So far I have been consulting several posts but none of them helpd me solve the problem.
  I came across <a href="https://stackoverflow.com/questions/44064474/few-shell-commands-doesnt-work-when-i-invoke-a-script-via-qprocess-in-qt">this one</a> and also <a href="https://stackoverflow.com/questions/9086771/how-to-start-a-shell-script-with-qprocess">this one</a> from which I actually got the idea.</p>
  
  <p>As interpreter I tried both <code>"/bin/sh"</code> and <code>"sh"</code> but none of them gave the expected result.
  To be precise I tried both this one:</p>
  
  <pre><code>  executeBash-&gt;start("sh",QStringList() &lt;&lt; script);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>  executeBash-&gt;start("/bin/sh",QStringList() &lt;&lt; script);
  </code></pre>
  
  <p>But nothing happened.</p>
  
  <p>I finally came across <a href="https://stackoverflow.com/questions/40407394/qt-run-shell-commands-via-qprocess">this</a> very useful post which actually helped me set up the whole button function, but when it was time to execute the script nothing happens this time too.</p>
  
  <p>I am not sure if this strange behavior is caused by the <code>connect</code> function in the constructor. The problem is also that the <code>qDebug()</code> statement is also never reached.</p>
  
  <p>The <a href="https://doc.qt.io/qt-5/qprocess.html#startDetached" rel="nofollow noreferrer">official documentation</a> mention the possibility to use a <code>startDetached</code> statement but I am not sure it can fully relate to what I am trying to achieve.
  Always the official documentation reports the following statement <a href="https://doc.qt.io/qt-5/qprocess.html#startDetached" rel="nofollow noreferrer">here</a></p>
  
  <blockquote>
    <p>Unix: The started process will run in its own session and act like a
    daemon.</p>
  </blockquote>
  
  <p>And therefore I thought that there was a process session working and that could be executed but it is not.</p>
  
  <p>In conclusion: I have been researching a lot what the problem might be but I keep missing something I don't see. Please point to the right direction to help solving this issue is anyone happened to have the same problem.</p>