Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. command chaining didn't work and no value
QtWS25 Last Chance

command chaining didn't work and no value

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 4 Posters 415 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • darongyiD Offline
    darongyiD Offline
    darongyi
    wrote on last edited by kshegunov
    #1

    I try to run this command using QProcess

    curl "http://dbpedia.org/data/Haeinsa.json" | perl dbpediaPlaceData.txt 'Haeinsa'
    

    I made QObject class and used timer . I can't get value from perlProcess.
    Data is Json value.

    ProcessManager::ProcessManager(const QString& keyword,int max_processes, QObject *parent) :
          QObject(parent),
          _num_process(1)
          ,_max_processes(max_processes)
           ,curlProcess(new QProcess(this))
          ,perlProcess(new QProcess(this))
          ,dbpediaPlaceFile("")
          ,mKeyword(keyword)
    
    {
        createPath();
        perlProcess->setStandardOutputProcess(perlProcess);
    
        QUrl baseUrl = QUrl(QString("http://dbpedia.org/data/%1.json").arg(mKeyword));
        qDebug() << baseUrl;
    
        // declare arguments
        curlArguements << "-s"
                        << baseUrl.toString();
    
        perlArguments <<  dbpediaPlaceFile <<" " << mKeyword;
    
        _timer = new QTimer();
        _timer->setInterval(100);
    
        connect(_timer, &QTimer::timeout, this, QOverload<>::of(&ProcessManager::start_process));
    
    }
    
    bool ProcessManager::start_process(QString name)
    {
        // Use resizable buffers, unlike the system.
       QByteArray byteerr;
       QByteArray byteout;
    
     QString dbpediaPlaceFile = "dbpediaPlaceFile.txt";
    
        curlProcess->start("curl", {"-s", "http://dbpedia.org/data/Haeinsa.json"});
    
        if (curlProcess->waitForFinished(-1))
         {
            // perlProcess->setProcessChannelMode(QProcess::ForwardedChannels);
             perlProcess->start("perl",  { dbpediaPlaceFile, "Haeinsa"});
    
             QByteArray byteData = curlProcess->readAll();
              perlProcess->write(byteData);
             perlProcess->closeWriteChannel();
    
         perlProcess->waitForStarted();
    
         do {
                 
             byteerr += perlProcess->readAllStandardError();
             byteout += perlProcess->readAllStandardOutput();
    
             qDebug() << byteerr;
             qDebug() << byteout;
         }
             // Wait 100 ms and keep looping if not finished.
         while ( !perlProcess->waitForFinished(1000) );
    
             // Make sure you catch any leftovers.
         byteerr += perlProcess->readAllStandardError();
         byteout += perlProcess->readAllStandardOutput();
    
         qDebug() << byteerr;
         qDebug() << byteout;
    
         }
    
     //_timer->stop();
    }
    

    [Locked as duplicate ~kshegunov]

    K jsulmJ 2 Replies Last reply
    0
    • darongyiD darongyi

      I try to run this command using QProcess

      curl "http://dbpedia.org/data/Haeinsa.json" | perl dbpediaPlaceData.txt 'Haeinsa'
      

      I made QObject class and used timer . I can't get value from perlProcess.
      Data is Json value.

      ProcessManager::ProcessManager(const QString& keyword,int max_processes, QObject *parent) :
            QObject(parent),
            _num_process(1)
            ,_max_processes(max_processes)
             ,curlProcess(new QProcess(this))
            ,perlProcess(new QProcess(this))
            ,dbpediaPlaceFile("")
            ,mKeyword(keyword)
      
      {
          createPath();
          perlProcess->setStandardOutputProcess(perlProcess);
      
          QUrl baseUrl = QUrl(QString("http://dbpedia.org/data/%1.json").arg(mKeyword));
          qDebug() << baseUrl;
      
          // declare arguments
          curlArguements << "-s"
                          << baseUrl.toString();
      
          perlArguments <<  dbpediaPlaceFile <<" " << mKeyword;
      
          _timer = new QTimer();
          _timer->setInterval(100);
      
          connect(_timer, &QTimer::timeout, this, QOverload<>::of(&ProcessManager::start_process));
      
      }
      
      bool ProcessManager::start_process(QString name)
      {
          // Use resizable buffers, unlike the system.
         QByteArray byteerr;
         QByteArray byteout;
      
       QString dbpediaPlaceFile = "dbpediaPlaceFile.txt";
      
          curlProcess->start("curl", {"-s", "http://dbpedia.org/data/Haeinsa.json"});
      
          if (curlProcess->waitForFinished(-1))
           {
              // perlProcess->setProcessChannelMode(QProcess::ForwardedChannels);
               perlProcess->start("perl",  { dbpediaPlaceFile, "Haeinsa"});
      
               QByteArray byteData = curlProcess->readAll();
                perlProcess->write(byteData);
               perlProcess->closeWriteChannel();
      
           perlProcess->waitForStarted();
      
           do {
                   
               byteerr += perlProcess->readAllStandardError();
               byteout += perlProcess->readAllStandardOutput();
      
               qDebug() << byteerr;
               qDebug() << byteout;
           }
               // Wait 100 ms and keep looping if not finished.
           while ( !perlProcess->waitForFinished(1000) );
      
               // Make sure you catch any leftovers.
           byteerr += perlProcess->readAllStandardError();
           byteout += perlProcess->readAllStandardOutput();
      
           qDebug() << byteerr;
           qDebug() << byteout;
      
           }
      
       //_timer->stop();
      }
      

      [Locked as duplicate ~kshegunov]

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @darongyi

      AFAIK I have seen this post already this morning.

      Now it seemed to be gone. Please do not delete a post and repost for catching attention.

      Vote the answer(s) that helped you to solve your issue(s)

      JonBJ 1 Reply Last reply
      3
      • K koahnig

        @darongyi

        AFAIK I have seen this post already this morning.

        Now it seemed to be gone. Please do not delete a post and repost for catching attention.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @koahnig
        I've already answered @darongyi in https://forum.qt.io/topic/93698/can-t-get-value-from-command-chaining

        1 Reply Last reply
        2
        • darongyiD darongyi

          I try to run this command using QProcess

          curl "http://dbpedia.org/data/Haeinsa.json" | perl dbpediaPlaceData.txt 'Haeinsa'
          

          I made QObject class and used timer . I can't get value from perlProcess.
          Data is Json value.

          ProcessManager::ProcessManager(const QString& keyword,int max_processes, QObject *parent) :
                QObject(parent),
                _num_process(1)
                ,_max_processes(max_processes)
                 ,curlProcess(new QProcess(this))
                ,perlProcess(new QProcess(this))
                ,dbpediaPlaceFile("")
                ,mKeyword(keyword)
          
          {
              createPath();
              perlProcess->setStandardOutputProcess(perlProcess);
          
              QUrl baseUrl = QUrl(QString("http://dbpedia.org/data/%1.json").arg(mKeyword));
              qDebug() << baseUrl;
          
              // declare arguments
              curlArguements << "-s"
                              << baseUrl.toString();
          
              perlArguments <<  dbpediaPlaceFile <<" " << mKeyword;
          
              _timer = new QTimer();
              _timer->setInterval(100);
          
              connect(_timer, &QTimer::timeout, this, QOverload<>::of(&ProcessManager::start_process));
          
          }
          
          bool ProcessManager::start_process(QString name)
          {
              // Use resizable buffers, unlike the system.
             QByteArray byteerr;
             QByteArray byteout;
          
           QString dbpediaPlaceFile = "dbpediaPlaceFile.txt";
          
              curlProcess->start("curl", {"-s", "http://dbpedia.org/data/Haeinsa.json"});
          
              if (curlProcess->waitForFinished(-1))
               {
                  // perlProcess->setProcessChannelMode(QProcess::ForwardedChannels);
                   perlProcess->start("perl",  { dbpediaPlaceFile, "Haeinsa"});
          
                   QByteArray byteData = curlProcess->readAll();
                    perlProcess->write(byteData);
                   perlProcess->closeWriteChannel();
          
               perlProcess->waitForStarted();
          
               do {
                       
                   byteerr += perlProcess->readAllStandardError();
                   byteout += perlProcess->readAllStandardOutput();
          
                   qDebug() << byteerr;
                   qDebug() << byteout;
               }
                   // Wait 100 ms and keep looping if not finished.
               while ( !perlProcess->waitForFinished(1000) );
          
                   // Make sure you catch any leftovers.
               byteerr += perlProcess->readAllStandardError();
               byteout += perlProcess->readAllStandardOutput();
          
               qDebug() << byteerr;
               qDebug() << byteout;
          
               }
          
           //_timer->stop();
          }
          

          [Locked as duplicate ~kshegunov]

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @darongyi This is already third thread with same question! Why?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved