Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. bash befehl ausführen und ausgeben!
Forum Updated to NodeBB v4.3 + New Features

bash befehl ausführen und ausgeben!

Scheduled Pinned Locked Moved Unsolved German
11 Posts 4 Posters 1.5k 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.
  • G Offline
    G Offline
    gerasifbesmumu
    wrote on last edited by gerasifbesmumu
    #1

    wie kann ich, bash befehl ausführen und ausgeben!?
    C++

    z.B

    bash befehl  "uname -m ",
    ergibt ergebnis "x86_64"
    
    dieser ergebnis soll in QLineEdit ausgeben
     "ui->VersText->setText(C"????" );"
    jsulmJ 1 Reply Last reply
    0
    • G gerasifbesmumu

      wie kann ich, bash befehl ausführen und ausgeben!?
      C++

      z.B

      bash befehl  "uname -m ",
      ergibt ergebnis "x86_64"
      
      dieser ergebnis soll in QLineEdit ausgeben
       "ui->VersText->setText(C"????" );"
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @gerasifbesmumu https://doc.qt.io/qt-6/qprocess.html

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

      G 1 Reply Last reply
      2
      • jsulmJ jsulm

        @gerasifbesmumu https://doc.qt.io/qt-6/qprocess.html

        G Offline
        G Offline
        gerasifbesmumu
        wrote on last edited by
        #3

        @jsulm
        das ist klar, das mit "QProcess" lauft

        wie krieg ich ergebnis in "QLineEdit" ?

        jsulmJ 1 Reply Last reply
        0
        • G gerasifbesmumu

          @jsulm
          das ist klar, das mit "QProcess" lauft

          wie krieg ich ergebnis in "QLineEdit" ?

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

          @gerasifbesmumu Hast du "Communicating via Channels" Kapitel gelesen? Verbinde einen Slot mit readyReadStandardOutput() und lese stdout von dem Prozess mit https://doc.qt.io/qt-6/qprocess.html#readAllStandardOutput

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

          G 1 Reply Last reply
          3
          • jsulmJ jsulm

            @gerasifbesmumu Hast du "Communicating via Channels" Kapitel gelesen? Verbinde einen Slot mit readyReadStandardOutput() und lese stdout von dem Prozess mit https://doc.qt.io/qt-6/qprocess.html#readAllStandardOutput

            G Offline
            G Offline
            gerasifbesmumu
            wrote on last edited by
            #5

            @jsulm kannst du mir einfach code geben ?

            J.HilkJ jsulmJ 2 Replies Last reply
            0
            • G gerasifbesmumu

              @jsulm kannst du mir einfach code geben ?

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @gerasifbesmumu könnte man ja.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              1
              • G gerasifbesmumu

                @jsulm kannst du mir einfach code geben ?

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

                @gerasifbesmumu Warum sollte ich?
                Hast überhaupt versucht es selber zu machen?

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

                G 1 Reply Last reply
                2
                • jsulmJ jsulm

                  @gerasifbesmumu Warum sollte ich?
                  Hast überhaupt versucht es selber zu machen?

                  G Offline
                  G Offline
                  gerasifbesmumu
                  wrote on last edited by
                  #8

                  @jsulm said in bash befehl ausführen und ausgeben!:

                  @gerasifbesmumu Warum sollte ich?
                  Hast überhaupt versucht es selber zu machen?

                  ja ich habe versucht,
                  klappt nicht!

                  jsulmJ 1 Reply Last reply
                  0
                  • G gerasifbesmumu

                    @jsulm said in bash befehl ausführen und ausgeben!:

                    @gerasifbesmumu Warum sollte ich?
                    Hast überhaupt versucht es selber zu machen?

                    ja ich habe versucht,
                    klappt nicht!

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

                    @gerasifbesmumu Dann zeig den Code und sag uns was genau nicht funktioniert

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

                    G 1 Reply Last reply
                    2
                    • jsulmJ jsulm

                      @gerasifbesmumu Dann zeig den Code und sag uns was genau nicht funktioniert

                      G Offline
                      G Offline
                      gerasifbesmumu
                      wrote on last edited by gerasifbesmumu
                      #10

                      @jsulm

                      #include <QProcess>
                      #include <QString>
                      
                      
                      QProcess *proc = new QProcess(this);
                          QString cmd = "uname -n";
                          connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
                          proc->start("/bin/bash", QStringList() << "-c" << cmd);
                          proc->waitForFinished();
                      

                      hier rein

                      ui->VersText->setText(**?????**);
                      
                      JonBJ 1 Reply Last reply
                      0
                      • G gerasifbesmumu

                        @jsulm

                        #include <QProcess>
                        #include <QString>
                        
                        
                        QProcess *proc = new QProcess(this);
                            QString cmd = "uname -n";
                            connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
                            proc->start("/bin/bash", QStringList() << "-c" << cmd);
                            proc->waitForFinished();
                        

                        hier rein

                        ui->VersText->setText(**?????**);
                        
                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by
                        #11

                        @gerasifbesmumu
                        Also muessen Sie das slot readOutput() schreiben, um setText() zu ruefen.

                        Oder hier koennen Sie:

                            proc->start("/bin/bash", QStringList() << "-c" << cmd);
                            proc->waitForFinished();
                            QByteArray ba = proc->readAllStandardOuput();
                            ui->VersText->setText(ba);
                        

                        (Möglicherweise müssen Sie zwischen QByteArray und QString konvertieren, um setText() zu aufrufen.)

                        1 Reply Last reply
                        1

                        • Login

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