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. Able to get file SFTP on command line, but not using Qt Class QProcess (solved)
Forum Updated to NodeBB v4.3 + New Features

Able to get file SFTP on command line, but not using Qt Class QProcess (solved)

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    i am using ubuntu desktop and is able to SFTP on the command line.
    But not on Qt.Below is my debug message
    "sftp 127.0.0.1"
    "bash: line1: get: command not found"
    Please advice.

    @

    void MainWindow::getFuntion()
    {
    QProcess myProcess;
    QByteArray result;

    char* ipset="127.0.0.1";
    QString cmd= QString("sftp %1").arg(ipset);
    qDebug()<<cmd;
    
    //command string
    myProcess.setReadChannel(QProcess::StandardOutput);
    myProcess.setProcessChannelMode(QProcess::MergedChannels);
    myProcess.start("bash");
    
    if(!myProcess.waitForStarted()){
        qDebug()<<"Error: could not start terminal ::"<<endl;
    }
    

    // myProcess.write("passwrod");
    myProcess.write("get asd.txt");
    myProcess.closeWriteChannel(); //done writing.

    while(myProcess.state()!=QProcess::NotRunning){
          myProcess.waitForFinished();
          result=myProcess.readAll();
          qDebug()<<result;
    }
    

    }
    @

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You are not using the cmd variable anywhere in this code, only for printing. So what you effectively do in the process is this:
      @
      bash
      get asd.txt
      @

      And so bash complains it does not understand "get" command. You should either run sftp directly, or pass it first, before passing "get".

      (Z(:^

      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

        it work when the below code is edited.
        myProcess.start(cmd);

        OpenSSH prompted for password, is it possible to write the password in code first?
        without the pc prompting for password?
        myProcess.write("password");

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Some info can be found here: "link":http://serverfault.com/questions/74158/how-can-you-do-a-one-liner-with-sftp-to-login-with-the-password-on-the-same-line

          (Z(:^

          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