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. Problem with QProcess (extern Program)
Forum Update on Monday, May 27th 2025

Problem with QProcess (extern Program)

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 7 Posters 663 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.
  • 0 Offline
    0 Offline
    0815Joe
    wrote on 13 Jan 2021, 13:52 last edited by
    #1

    Hello Forum,

    as you probably already read in the headline, I have a problem with QProcess. I can't manage to start an external bash script with parameters.

    The program compiles without errors and can also be started and runs to the end, but without starting the script.

    I develop with the QT Creator on the OSX operating system (Big Sur).

    QString program = "bashscriptTest";
    QStringList arguments;
    arguments << "-o" << "TESTPARAMETER";
    
    QProcess myProcess ;
    myProcess.start(program, arguments);
    

    Kind regards
    0815Joe

    P J 2 Replies Last reply 13 Jan 2021, 15:02
    0
    • 0 0815Joe
      13 Jan 2021, 13:52

      Hello Forum,

      as you probably already read in the headline, I have a problem with QProcess. I can't manage to start an external bash script with parameters.

      The program compiles without errors and can also be started and runs to the end, but without starting the script.

      I develop with the QT Creator on the OSX operating system (Big Sur).

      QString program = "bashscriptTest";
      QStringList arguments;
      arguments << "-o" << "TESTPARAMETER";
      
      QProcess myProcess ;
      myProcess.start(program, arguments);
      

      Kind regards
      0815Joe

      P Online
      P Online
      Pl45m4
      wrote on 13 Jan 2021, 15:02 last edited by
      #2

      @0815Joe

      If you need a shell, you need to start the bash first.

      Something like:

      QString program = "/bin/sh";
      QStringList arguments;
      arguments << "bashscriptTest" << "-o" << "TESTPARAMETER";
      
      QProcess myProcess ;
      myProcess.start(program, arguments);
      

      might work.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      J 1 Reply Last reply 13 Jan 2021, 16:24
      1
      • 0 0815Joe
        13 Jan 2021, 13:52

        Hello Forum,

        as you probably already read in the headline, I have a problem with QProcess. I can't manage to start an external bash script with parameters.

        The program compiles without errors and can also be started and runs to the end, but without starting the script.

        I develop with the QT Creator on the OSX operating system (Big Sur).

        QString program = "bashscriptTest";
        QStringList arguments;
        arguments << "-o" << "TESTPARAMETER";
        
        QProcess myProcess ;
        myProcess.start(program, arguments);
        

        Kind regards
        0815Joe

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 13 Jan 2021, 16:18 last edited by
        #3

        @0815Joe To add to @Pl45m4 you should add error handling to get more information about what is failing.

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

        1 Reply Last reply
        1
        • P Pl45m4
          13 Jan 2021, 15:02

          @0815Joe

          If you need a shell, you need to start the bash first.

          Something like:

          QString program = "/bin/sh";
          QStringList arguments;
          arguments << "bashscriptTest" << "-o" << "TESTPARAMETER";
          
          QProcess myProcess ;
          myProcess.start(program, arguments);
          

          might work.

          J Offline
          J Offline
          JonB
          wrote on 13 Jan 2021, 16:24 last edited by JonB
          #4

          @Pl45m4 said in Problem with QProcess (extern Program):

          QString program = "/bin/sh";

          You might rather want QString program = "/bin/bash"; :D

          You could instead make the first line of your script be #!/bin/bash and make the file executable via chmod +x bashscriptTest. Then your original code of QString program = "bashscriptTest"; should work as-is (with its arguments).

          1 Reply Last reply
          1
          • 0 Offline
            0 Offline
            0815Joe
            wrote on 13 Jan 2021, 20:07 last edited by
            #5

            At first thank you all for your help.

            But nothing is working.

            M 1 Reply Last reply 13 Jan 2021, 20:09
            0
            • C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 13 Jan 2021, 20:09 last edited by
              #6

              @0815Joe said in Problem with QProcess (extern Program):

              But nothing is working.

              That's no proper error report. Please show what you've done.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • 0 0815Joe
                13 Jan 2021, 20:07

                At first thank you all for your help.

                But nothing is working.

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 13 Jan 2021, 20:09 last edited by
                #7

                @0815Joe

                Hi
                Where is the script ?
                You just say "bashscriptTest" (with no paths to the script file)
                so for Qt to find it, it must be right next to the .exe or
                in some place where it will search for it. (system paths)

                1 Reply Last reply
                1
                • JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on 13 Jan 2021, 22:06 last edited by JoeCFD
                  #8

                  your qt app path might be different from where the script is located. Add absolute path to bashscriptTest and your code will be good.

                  1 Reply Last reply
                  1
                  • 0 Offline
                    0 Offline
                    0815Joe
                    wrote on 14 Jan 2021, 07:21 last edited by
                    #9

                    @JoeCFD The bashscriptTest is also in the build path.
                    i will try the absolute path later today.

                    Then i am giving you an answer :-)

                    J 1 Reply Last reply 14 Jan 2021, 07:41
                    0
                    • 0 0815Joe
                      14 Jan 2021, 07:21

                      @JoeCFD The bashscriptTest is also in the build path.
                      i will try the absolute path later today.

                      Then i am giving you an answer :-)

                      J Offline
                      J Offline
                      JonB
                      wrote on 14 Jan 2021, 07:41 last edited by
                      #10

                      @0815Joe
                      I don't know what "the build path" is, but it doesn't sound like it would be available/have any significance at runtime (outside of Qt Creator).

                      0 1 Reply Last reply 8 Feb 2021, 15:00
                      0
                      • J JonB
                        14 Jan 2021, 07:41

                        @0815Joe
                        I don't know what "the build path" is, but it doesn't sound like it would be available/have any significance at runtime (outside of Qt Creator).

                        0 Offline
                        0 Offline
                        0815Joe
                        wrote on 8 Feb 2021, 15:00 last edited by
                        #11

                        Hello to all who helped me.

                        I am sorry, but my program worked from the beginning.

                        I just did not find the result file.

                        Problem: I have an OSX operating system and my GUI sample application is a package. In this package is also my result file. This I did not know and then of course overlooked.

                        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