Using Qt 5.6.0 & MSVC2015 I have an app which upon start-up, using QProcess and ssh/plink/cat, shall attempt to read the hostname of a remote server and capture the contents of a specific file on a remote server. This works when run from Qt Creator (the IDE), in either debug or release. If I attempt the same app from outside if Qt Creator, either the signal is never emitted or the slot is not called.
Here's the pertinent code bits:
void MainWindow::Perform1stSSHcmd()
{
QPalette palette;
// hostname: THIS IS OUR 1st SSH COMMAND SO WE WANT TO DETERMINE IF THE KEYS ARE SET UP OK...
QProcess* qp = new QProcess( this );
QString userAndCommand = "root@";
userAndCommand.append( m_cmsIp );
userAndCommand.append(" hostname"); // cmd we want to execute on the remote server
qp->start( m_plinkPuttyCmd.arg( userAndCommand ));
qp->waitForFinished( 16000 ); // I've tried vaious values for this
QString output = qp->readAll();
QString err = qp->readAllStandardError();
// ... SNIP various error checking here ...
// Now the system info
m_sysInfoProc = new QProcess(this);
qDebug() << "About to read systemInfo.xml... ";
if( !connect( this->m_sysInfoProc, SIGNAL( readyReadStandardOutput() ), SLOT( readSystemInfoXML() ))) {
qDebug() << "Connect Failed!!!!!";
}
userAndCommand = "root@";
userAndCommand.append( m_cmsIp );
qDebug() << "preparing cat of xml... ";
userAndCommand.append(" cat /root/systemInfo.xml");
m_sysInfoProc->start( m_plinkPuttyCmd.arg( userAndCommand ));
qDebug() << "->start issued... ";
m_sysInfoProc->waitForFinished( 6000 );
qDebug() << "after waitForFinished( 6000 )";
}
void MainWindow::readSystemInfoXML()
{
qDebug() << "In readSystemInfoXML()";
QProcess *systemInfoXml = qobject_cast<QProcess *>(sender());
if( !systemInfoXml ) {
return;
}
QString res = systemInfoXml->readAllStandardOutput();
qDebug() << "readSystemInfoXML() just read:" << res;
if( !res.length() ) {
return;
}
// . . . XML parsing of file contents . . . (not a concern, works fine)
}
Output Debug/Releas Mode from IDE:
Wed Sep 28 15:36:06 2016 Debug: output: "Lanner"
Wed Sep 28 15:36:06 2016 Debug: err: ""
Wed Sep 28 15:36:06 2016 Debug: About to read systemInfo.xml...
Wed Sep 28 15:36:06 2016 Debug: preparing cat of xml...
Wed Sep 28 15:36:06 2016 Debug: ->start issued...
Wed Sep 28 15:36:06 2016 Debug: In readSystemInfoXML()
Wed Sep 28 15:36:06 2016 Debug: readSystemInfoXML() just read: "\n \n\t2.50-06-15\n 1.0\n \tSINA\n \tclass IC\n \tdoes something\n \n"
Wed Sep 28 15:36:06 2016 Debug: after waitForFinished( 6000 )
Wed Sep 28 15:36:06 2016 Debug: ICICIC
(tags missing from xml dur to formatting, only values appear)
Now the release...
Output when started from release folder on my Windows box:
Wed Sep 28 15:38:09 2016 Debug: output: ""
Wed Sep 28 15:38:09 2016 Debug: err: ""
Wed Sep 28 15:38:09 2016 Debug: About to read systemInfo.xml...
Wed Sep 28 15:38:09 2016 Debug: preparing cat of xml...
Wed Sep 28 15:38:09 2016 Debug: ->start issued...
Wed Sep 28 15:38:09 2016 Debug: after waitForFinished( 6000 )
Wed Sep 28 15:38:09 2016 Debug: ICICIC
I've searched for others who may of had similar issues, the closest was Qt: some slots don't get executed in release mode
I've tried touching MainWindow.h, re-running qmake and build all, no luck.
Any advice would be greatly appreciated. Ian