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. [Ubuntu] how to run docker and redirect the output of docker using qt qprocess?

[Ubuntu] how to run docker and redirect the output of docker using qt qprocess?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 634 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    corehaha
    wrote on last edited by
    #1

    I want to run several commands and scripts in docker using qprocess. And redirecting the output of docker to qplaintext.But there is no result. Looking for help ! So how to run docker and redirect the output ????
    Here is my command list:

    command_list_<<"sh docker/scripts/dev_into.sh"<<"cyber_recorder record -a";
    

    docker/scripts/dev_into.sh is a script which get into my docker container

    cyber_recorder is a command existed in this container

    and using code following , my program can run command one by one;

        void(QProcess:: *finished)(int) = &QProcess::finished;
        connect(this->process,finished,this,[=](){
            if(!br->command_list().isEmpty())
            {
                process->start(command_list_.at(0));
                command_list_.removeFirst();
            }
        });
    

    Ps. Using qprocess to run echo $USER, the result is not my hostname ,but$USER.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you connect the QProcess::readyReadStandardOutput ? And use QProcess::readAllStandardOutput to read it ?

      You might want to do as well for the error channel.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • C Offline
        C Offline
        corehaha
        wrote on last edited by corehaha
        #3

        I've use readAll to read channel .

            connect(this->process,&QProcess::readyRead,this,[=](){
        
                QString result_ = process->readAll();
                todlg->pte->appendPlainText(result_);
        
            });
        
        1 Reply Last reply
        0
        • C Offline
          C Offline
          corehaha
          wrote on last edited by
          #4

          The problem now is I cannot get into docker using qprocess.Except I use qprocess to run gnome-terminal and indirectly into docker .

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Please share your code. It's just guesswork at this point.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            C 1 Reply Last reply
            0
            • SGaistS SGaist

              Please share your code. It's just guesswork at this point.

              C Offline
              C Offline
              corehaha
              wrote on last edited by
              #6

              @SGaist Using qprocess I've solved by executing the shell script instead of single command. Thank you anyway !!!!

              1 Reply Last reply
              0
              • JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #7

                @corehaha said in [Ubuntu] how to run docker and redirect the output of docker using qt qprocess?:

                command_list_<<"sh docker/scripts/dev_into.sh"<<"cyber_recorder record -a";

                You may try this out.

                QStringList arguments;
                arguments<< "docker/scripts/dev_into.sh"
                <<"cyber_recorder"
                << "record"
                << " -a";
                process->start( QString( "/bin/sh" ), arguments );

                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