title: tar command in execl using busybox. Error: no such file or directory
body: <p>I have a linux based device that runs c++ code using QT framework. Using QProcess is not an option, since we don't have the QT compiled to support it.</p>
  
  <p>I can't create a <code>tar.gz</code> archive using execl(). </p>
  
  <p>It returns -1(fail) and error is <code>"No such file or directory"</code></p>
  
  <p>Code sample:</p>
  
  <pre><code>std::string applicationPathWithName = "/bin/busybox";
  QString dataDirectory("/opt/appl/data/");
  QString archiveName = QString("AswLogs.tar.gz");
  char* applName;
  applName = new char [applicationPathWithName.size() + 1];
  strcpy(applName, applicationPathWithName.c_str());
  
  itsFlmFileManagerPtr-&gt;writeInFile(eFlmFileTypes_LogFile, data); //This creates logs.txt successfully
  
  pid_t pid = fork();
  
  QString command = QString("tar -czvf %1%2 %3logs.txt").arg(dataDirectory).arg(archiveName).arg(dataDirectory);
  
  if(0 == pid)
  {
      INFO("Pid is 0");
      int execStatus = 0;
      execStatus = execl(applName, applName, command.toStdString().c_str(), (char*)NULL);
      INFO("Execl is done, execStatus= " &lt;&lt; execStatus);
      std::string errorStr = strerror(errno);
      INFO("Error: " &lt;&lt; errorStr);
  
      _exit(EXIT_FAILURE);
  }
  else if (pid &lt; 0)
  {
      INFO("Failed to fork");
  }
  else
  {
      INFO("pid=" &lt;&lt; pid);
      int status;
      if(wait(&amp;status) == -1)
      {
          INFO("Wait child error");
      }
      INFO("Resume from fork");
  }
  </code></pre>
  
  <p>Output:</p>
  
  <p>pid=877</p>
  
  <p>Pid is 0 </p>
  
  <p>Execl is done, execStatus= -1 </p>
  
  <p>Error: No such file or directory</p>
  
  <p>Resume from fork</p>
  
  <p>Permissions:</p>
  
  <p>logs.txt 666 |
  busybox 755</p>
  
  <p>How can I get more error details or what is wrong here? </p>
  
  <p><code>Edit:</code>
  So, after a while, I tried to do just the .tar archive and it worked.
  Then I tried just to do the .gz compression and it also worked.</p>
  
  <p>Solution:
  So, at least in my case, the solution was to do the tar.gz in two steps(Two processes required):</p>
  
  <p><code>execl("/bin/busybox", "/bin/busybox", "tar", "-cvf", "/opt/appl/data/logs.tar", "/opt/appl/data/logs.txt", (char*) NULL);</code></p>
  
  <p><code>execl("/bin/busybox", "/bin/busybox", "gzip", "/opt/appl/data/logs.tar", (char*) NULL);</code></p>