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
Forum Updated to NodeBB v4.3 + New Features

Run bash script from qt

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 5.7k 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.
  • WaseeW Offline
    WaseeW Offline
    Wasee
    wrote on last edited by
    #3

    @jsulm Hi;
    still getting the same error.

    jsulmJ 1 Reply Last reply
    0
    • WaseeW Wasee

      @jsulm Hi;
      still getting the same error.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      • WaseeW Wasee

        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

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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
        • WaseeW Offline
          WaseeW Offline
          Wasee
          wrote on last edited by
          #6

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

          thanks

          jsulmJ 1 Reply Last reply
          0
          • WaseeW Wasee

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

            thanks

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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
            • JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on 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
              • WaseeW Offline
                WaseeW Offline
                Wasee
                wrote on 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.

                jsulmJ 1 Reply Last reply
                0
                • WaseeW Wasee

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

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 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
                  • WaseeW Offline
                    WaseeW Offline
                    Wasee
                    wrote on 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

                    jsulmJ JonBJ 2 Replies Last reply
                    0
                    • WaseeW Wasee

                      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

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 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
                      • WaseeW Wasee

                        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

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on 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

                        • Login

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