c++qtqprocessqtcorepscp

Using QProcess for CLI


How can I use QProcess for Command Line Interactive arguments, I am trying to a transfer a file usimg scp which prompts for password

QString program = "c:/temp/pscp.exe";
QStringList arguments;
arguments << "C:/Users/polaris8/Desktop/Test1GB.zip" <<   "Mrigendra@192.168.26.142:/home/";
QPointer<QProcess> myProcess;
myProcess = new QProcess;
connect(myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
myProcess->start(program , arguments);

After this the commnad Line asks for Password how to satisfy it using QProcess , can I overcome it by giving some options in my arguments only for scp, or what should be the code in my slot readOutput that throws the password to Command Line . Any suggestions would be helpful. Thanks


Solution

  • I think you can pass the username / password as options with:

    -l user
    -pw passwd
    

    So your arguments should look like this:

    QStringList arguments;
    arguments << "-l" << "Mrigendra" << "-pw" << "Password" <<
                 "C:/Users/polaris8/Desktop/Test1GB.zip" <<
                 "192.168.26.142:/home/";