I want am trying to use QProcess to launch sftp on a linux system, in my code:
QProcess* pProc = new QProcess(this);
QString strHost = clsMainWnd::strGetHostName()
,strPort = clsMainWnd::strGetPort()
,strUsername = clsMainWnd::strGetUsername();
QStringList slstCmdArgs;
slstCmdArgs << (strUsername + QString("@") + strHost)
<< (QString("-P") + strPort);
pProc->start("sftp", slstCmdArgs);
while( pProc->waitForStarted() != true ) {
}
QByteArray bytaryIn = pProc->readAllStandardOutput();
qDebug() << bytaryIn;
What I want to do is wait for the "Password:" prompt then inject the password, but bytaryIn is always empty.
I've verified the command line arguments are correctly formatted and output to the console.
I've then used these in a terminal to test and they work as expected.
The command will be formatted as:
sftp User@HostName -P22
[Edit] I've re-written this code to the following:
QString strHost = clsMainWnd::strGetHostName()
,strPort = clsMainWnd::strGetPort()
,strUsername = clsMainWnd::strGetUsername();
QStringList slstCmdArgs;
slstCmdArgs << (strUsername + QString("@") + strHost)
<< (QString("-P") + strPort);
mpSFTP = new QProcess(this);
connect(mpSFTP, SIGNAL(readyReadStandardOutput())
,this, SLOT(readSFTPoutput()));
mpSFTP->start("sftp", slstCmdArgs);
I have a debug statement in the slot, but I never see it, so the signal is not getting emitted.