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. Run bash script from qt

Run bash script from qt

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 5.5k 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.
  • W Offline
    W Offline
    Wasee
    wrote on 3 Dec 2021, 12:30 last edited by
    #1

    Hi everyone;
    I am running the bash script from qt creator and following the code.
    /@
    QProcess process ;
    process.startDetached("/bin/bash", QStringList() << "/home/Documents/testing/script.sh");
    @/
    But getting error No directory found even my directory path is correct.
    thanks

    J J 2 Replies Last reply 3 Dec 2021, 12:33
    0
    • W Wasee
      3 Dec 2021, 12:30

      Hi everyone;
      I am running the bash script from qt creator and following the code.
      /@
      QProcess process ;
      process.startDetached("/bin/bash", QStringList() << "/home/Documents/testing/script.sh");
      @/
      But getting error No directory found even my directory path is correct.
      thanks

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 3 Dec 2021, 12:33 last edited by
      #2

      @Wasee said in Run bash script from qt:

      process.startDetached("/bin/bash", QStringList() << "/home/Documents/testing/script.sh");

      process.startDetached("/bin/bash", QStringList() << "-c" << "/home/Documents/testing/script.sh");
      

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

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wasee
        wrote on 3 Dec 2021, 12:41 last edited by
        #3

        @jsulm Hi;
        still getting the same error.

        J 1 Reply Last reply 3 Dec 2021, 12:43
        0
        • W Wasee
          3 Dec 2021, 12:41

          @jsulm Hi;
          still getting the same error.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 3 Dec 2021, 12:43 last edited by
          #4

          @Wasee Please post the whole error message.

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

          1 Reply Last reply
          1
          • W Wasee
            3 Dec 2021, 12:30

            Hi everyone;
            I am running the bash script from qt creator and following the code.
            /@
            QProcess process ;
            process.startDetached("/bin/bash", QStringList() << "/home/Documents/testing/script.sh");
            @/
            But getting error No directory found even my directory path is correct.
            thanks

            J Online
            J Online
            JonB
            wrote on 3 Dec 2021, 12:49 last edited by
            #5

            @Wasee said in Run bash script from qt:

            process.startDetached("/bin/bash", QStringList() << "/home/Documents/testing/script.sh");

            But getting error No directory found even my directory path is correct.

            So you're sure that directory path is correct and exists, it isn't supposed to be "/home/my_user_name/Documents/..."? :)

            1 Reply Last reply
            1
            • W Offline
              W Offline
              Wasee
              wrote on 3 Dec 2021, 12:52 last edited by
              #6

              @jsulm Hi;
              This is the error:
              /bin/bash: /home/Documents/testing/script.sh: No such file or directory

              thanks

              J 1 Reply Last reply 3 Dec 2021, 12:54
              0
              • W Wasee
                3 Dec 2021, 12:52

                @jsulm Hi;
                This is the error:
                /bin/bash: /home/Documents/testing/script.sh: No such file or directory

                thanks

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 3 Dec 2021, 12:54 last edited by
                #7

                @Wasee said in Run bash script from qt:

                /home/Documents/testing/script.sh

                As @JonB said: this path looks wrong. There should be user name in it, like: /home/YOUR_USER_NAME/Documents/testing/script.sh

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

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JoeCFD
                  wrote on 4 Dec 2021, 00:33 last edited by
                  #8

                  auto docu_path = QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation );
                  process.startDetached("/bin/bash", QStringList() << QString( "%1/testing/script.sh").arg( docu_path );

                  1 Reply Last reply
                  0
                  • W Offline
                    W Offline
                    Wasee
                    wrote on 7 Dec 2021, 03:43 last edited by
                    #9

                    @jsulm @JonB @JoeCFD Hi;
                    My application crashes with ASSERT failure in QList<T>: index out of range.
                    The program has finished unexpectedly.

                    J 1 Reply Last reply 7 Dec 2021, 06:25
                    0
                    • W Wasee
                      7 Dec 2021, 03:43

                      @jsulm @JonB @JoeCFD Hi;
                      My application crashes with ASSERT failure in QList<T>: index out of range.
                      The program has finished unexpectedly.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 7 Dec 2021, 06:25 last edited by
                      #10

                      @Wasee said in Run bash script from qt:

                      My application crashes with ASSERT failure in QList<T>: index out of range.

                      Then fix your code.
                      You are accessing your QList outside of its bounds.
                      Really not hard to fix, instead of wasting time asking such basic stuff in a forum...
                      And do you really think you provided enough information for others to help you?
                      How should anybody know what list it is and how you are using it if you don't even bother to show relevant code?

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

                      1 Reply Last reply
                      2
                      • W Offline
                        W Offline
                        Wasee
                        wrote on 9 Dec 2021, 04:22 last edited by
                        #11

                        Hi everyone;
                        I need to pass the arguments with bash script from qt. How its will possible with following example.
                        /@
                        process.startDetached("/bin/bash", QStringList() << "-c" << "/home/Documents/testing/script.sh");
                        @/
                        thanks

                        J J 2 Replies Last reply 9 Dec 2021, 07:30
                        0
                        • W Wasee
                          9 Dec 2021, 04:22

                          Hi everyone;
                          I need to pass the arguments with bash script from qt. How its will possible with following example.
                          /@
                          process.startDetached("/bin/bash", QStringList() << "-c" << "/home/Documents/testing/script.sh");
                          @/
                          thanks

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 9 Dec 2021, 07:30 last edited by
                          #12

                          @Wasee said in Run bash script from qt:

                          process.startDetached("/bin/bash", QStringList() << "-c" << "/home/Documents/testing/script.sh");

                          QProcess::startDetached("/bin/bash", QStringList() << "-c" << QString("/home/johann/script.sh %1").arg(someParameter));
                          

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

                          1 Reply Last reply
                          1
                          • W Wasee
                            9 Dec 2021, 04:22

                            Hi everyone;
                            I need to pass the arguments with bash script from qt. How its will possible with following example.
                            /@
                            process.startDetached("/bin/bash", QStringList() << "-c" << "/home/Documents/testing/script.sh");
                            @/
                            thanks

                            J Online
                            J Online
                            JonB
                            wrote on 9 Dec 2021, 09:31 last edited by
                            #13

                            @Wasee
                            @jsulm's code is correct. However, there will be a "wrinkle" if your someParameter argument has any spaces in it. I don't want to complicate things unnecessarily, so if that is the case let us know, otherwise just follow that code.

                            1 Reply Last reply
                            1

                            9/13

                            7 Dec 2021, 03:43

                            • Login

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