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. request about scp command (QProcess) using qt
Forum Updated to NodeBB v4.3 + New Features

request about scp command (QProcess) using qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
29 Posts 4 Posters 4.8k Views 2 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.
  • jsulmJ jsulm

    @hlowd said in request about scp command (QProcess) using qt:

    Can I do it this way?

    Yes, just try.
    I would also execute scp using this absolute path in a terminal to make sure it works.

    H Offline
    H Offline
    hlowd
    wrote on last edited by
    #18

    @jsulm

    There are files in that path.

    C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb
    
    scp.exe
    ssh-add.exe
    ssh-agent.exe
    ssh-keygen.exe
    

    // new code

    QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
    

    // error message

    "CreateProcessW failed error:2 posix_spawn: No such file or directory"
    

    The same error occurs in the command prompt.

    JonBJ jsulmJ 2 Replies Last reply
    0
    • H hlowd

      @jsulm

      There are files in that path.

      C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb
      
      scp.exe
      ssh-add.exe
      ssh-agent.exe
      ssh-keygen.exe
      

      // new code

      QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
      

      // error message

      "CreateProcessW failed error:2 posix_spawn: No such file or directory"
      

      The same error occurs in the command prompt.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #19

      @hlowd
      I am not a total Windows expert, but I did not think you should ever attempt to run anything in the WinSxS area? You should be running the scp which is on your PATH (presumably).

      1 Reply Last reply
      0
      • H hlowd

        @jsulm

        There are files in that path.

        C:\Windows\WinSxS\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb
        
        scp.exe
        ssh-add.exe
        ssh-agent.exe
        ssh-keygen.exe
        

        // new code

        QString strParam = "C:\\Windows\\WinSxS\\amd64_openssh-common-components-onecore_31bf3856ad364e35_10.0.22621.1_none_1e3c4880a37d88bb\\scp.exe";
        

        // error message

        "CreateProcessW failed error:2 posix_spawn: No such file or directory"
        

        The same error occurs in the command prompt.

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

        @hlowd Did scp executable ever work for you in terminal? The path where it is located looks strange, don't know from where it comes. On my machine I have it here: c:\windows\System32\OpenSSH\scp.exe

        You can check where your scp.exe is located using this command:

        where scp
        

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

        H 1 Reply Last reply
        2
        • jsulmJ jsulm

          @hlowd Did scp executable ever work for you in terminal? The path where it is located looks strange, don't know from where it comes. On my machine I have it here: c:\windows\System32\OpenSSH\scp.exe

          You can check where your scp.exe is located using this command:

          where scp
          
          H Offline
          H Offline
          hlowd
          wrote on last edited by
          #21

          @jsulm

          The scp.exe file exists in that path.

          C:\Windows\System32\OpenSSH
          

          I don't know why I couldn't find it using Explorer search.

          jsulmJ 1 Reply Last reply
          0
          • H hlowd

            @jsulm

            The scp.exe file exists in that path.

            C:\Windows\System32\OpenSSH
            

            I don't know why I couldn't find it using Explorer search.

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

            @hlowd said in request about scp command (QProcess) using qt:

            The scp.exe file exists in that path

            Does it work with this path?

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

            H 1 Reply Last reply
            0
            • jsulmJ jsulm

              @hlowd said in request about scp command (QProcess) using qt:

              The scp.exe file exists in that path

              Does it work with this path?

              H Offline
              H Offline
              hlowd
              wrote on last edited by
              #23
              This post is deleted!
              1 Reply Last reply
              0
              • H Offline
                H Offline
                hlowd
                wrote on last edited by hlowd
                #24

                @jsulm
                No, it doesn't work..

                JonBJ 1 Reply Last reply
                0
                • H hlowd

                  @jsulm
                  No, it doesn't work..

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #25

                  @hlowd
                  This really should not be too difficult to diagnose, if you stick to what is suggested and report behaviour.

                  First try both of

                  scp
                  \full\path\to\scp
                  

                  in a Command Prompt. I assume at least one "works", and produces a "usage" output message?

                  Whichever produces the message, now try from a Qt program

                  QProcess proc;
                  proc.start(".....");    // here try whichever worked in Command Prompt
                  qDebug() << proc.waitForFinished();
                  qDebug() << proc.readAll();
                  

                  and report output.

                  H 1 Reply Last reply
                  1
                  • JonBJ JonB

                    @hlowd
                    This really should not be too difficult to diagnose, if you stick to what is suggested and report behaviour.

                    First try both of

                    scp
                    \full\path\to\scp
                    

                    in a Command Prompt. I assume at least one "works", and produces a "usage" output message?

                    Whichever produces the message, now try from a Qt program

                    QProcess proc;
                    proc.start(".....");    // here try whichever worked in Command Prompt
                    qDebug() << proc.waitForFinished();
                    qDebug() << proc.readAll();
                    

                    and report output.

                    H Offline
                    H Offline
                    hlowd
                    wrote on last edited by
                    #26

                    @JonB

                    it works(data is output)

                    • output 1 : true
                    • output 2 : "\r\nWindows IP ....."
                    QProcess proc;
                    proc.start("ipconfig /all");
                    qDebug() << "output 1 : " << proc.waitForFinished();
                    qDebug() << "output 2 : " << proc.readAll();
                    

                    do not Working

                    • output 1 : false
                    • output 2 : ""
                    QProcess proc;
                    proc.start("scp C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                    qDebug() << "output 1 : " << proc.waitForFinished();
                    qDebug() << "output 2 : " << proc.readAll();
                    

                    this is also do not working

                    • output 1 : false
                    • output 2 : ""
                    QProcess proc;
                        proc.start("C:\\Windows\\System32\\OpenSSH\\scp.exe C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                        qDebug() << "output 1 : " << proc.waitForFinished();
                        qDebug() << "output 2 : " << proc.readAll();
                    
                    jsulmJ Pl45m4P JonBJ 3 Replies Last reply
                    0
                    • H hlowd

                      @JonB

                      it works(data is output)

                      • output 1 : true
                      • output 2 : "\r\nWindows IP ....."
                      QProcess proc;
                      proc.start("ipconfig /all");
                      qDebug() << "output 1 : " << proc.waitForFinished();
                      qDebug() << "output 2 : " << proc.readAll();
                      

                      do not Working

                      • output 1 : false
                      • output 2 : ""
                      QProcess proc;
                      proc.start("scp C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                      qDebug() << "output 1 : " << proc.waitForFinished();
                      qDebug() << "output 2 : " << proc.readAll();
                      

                      this is also do not working

                      • output 1 : false
                      • output 2 : ""
                      QProcess proc;
                          proc.start("C:\\Windows\\System32\\OpenSSH\\scp.exe C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                          qDebug() << "output 1 : " << proc.waitForFinished();
                          qDebug() << "output 2 : " << proc.readAll();
                      
                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #27

                      @hlowd Could you please read QProcess documentation?!
                      The way you're using QProcess is wrong: all parameters should be part of arguments list. And what about adding error handling as already suggested?

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

                      1 Reply Last reply
                      2
                      • H hlowd

                        @JonB

                        it works(data is output)

                        • output 1 : true
                        • output 2 : "\r\nWindows IP ....."
                        QProcess proc;
                        proc.start("ipconfig /all");
                        qDebug() << "output 1 : " << proc.waitForFinished();
                        qDebug() << "output 2 : " << proc.readAll();
                        

                        do not Working

                        • output 1 : false
                        • output 2 : ""
                        QProcess proc;
                        proc.start("scp C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                        qDebug() << "output 1 : " << proc.waitForFinished();
                        qDebug() << "output 2 : " << proc.readAll();
                        

                        this is also do not working

                        • output 1 : false
                        • output 2 : ""
                        QProcess proc;
                            proc.start("C:\\Windows\\System32\\OpenSSH\\scp.exe C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                            qDebug() << "output 1 : " << proc.waitForFinished();
                            qDebug() << "output 2 : " << proc.readAll();
                        
                        Pl45m4P Offline
                        Pl45m4P Offline
                        Pl45m4
                        wrote on last edited by
                        #28

                        @hlowd said in request about scp command (QProcess) using qt:

                        proc.start("scp C:\Users\user\a.ini user@192.168.1.250:/home/user/SW/");

                        You need argument list for QProcess
                        The whole statement in start wont work.

                        Here in your similar topic is an example by @ChrisW67 and me..

                        • https://forum.qt.io/topic/152140/shellexecute-사용-관련-문의

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

                        ~E. W. Dijkstra

                        1 Reply Last reply
                        0
                        • H hlowd

                          @JonB

                          it works(data is output)

                          • output 1 : true
                          • output 2 : "\r\nWindows IP ....."
                          QProcess proc;
                          proc.start("ipconfig /all");
                          qDebug() << "output 1 : " << proc.waitForFinished();
                          qDebug() << "output 2 : " << proc.readAll();
                          

                          do not Working

                          • output 1 : false
                          • output 2 : ""
                          QProcess proc;
                          proc.start("scp C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                          qDebug() << "output 1 : " << proc.waitForFinished();
                          qDebug() << "output 2 : " << proc.readAll();
                          

                          this is also do not working

                          • output 1 : false
                          • output 2 : ""
                          QProcess proc;
                              proc.start("C:\\Windows\\System32\\OpenSSH\\scp.exe C:\\Users\\user\\a.ini user@192.168.1.250:/home/user/SW/");
                              qDebug() << "output 1 : " << proc.waitForFinished();
                              qDebug() << "output 2 : " << proc.readAll();
                          
                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #29

                          @hlowd
                          So, as I suspected, this shows you are not using QProcess::start() correctly. (It is also not the same as the code you posted in earlier, which was correct at one point.) Which is why I asked you to clarify this. If start("scp", ...) or start("/path/to/scp", ...) run the scp executable, and perhaps produce "usage" output you can capture, it shows that is working.

                          Your other attempts should all indeed fail as you incorrectly try to pass arguments in the string which should be the executable. The example at https://doc.qt.io/qt-6/qprocess.html#running-a-process shows how to do this correctly. If you are on Qt 6.0+ there is a new method, startCommand(), which works the way you tried, if you really want to do it that way.

                          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