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.
void MainWindow::Perform1stSSHcmd()
{
// hostname: THIS IS OUR 1st SSH COMMAND SO WE WANT TO DETERMINE IF THE KEYS ARE SET UP OK...
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 err
= qp
->readAllStandardError
();
// ... SNIP various error checking here ...
// Now the system info
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)
}
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)
}
To copy to clipboard, switch view to plain text mode
Output Debug/Releas Mode from IDE:
==================================
Wed Sep 28 15:36:06 2016 Debug: output: "Lanner\n"
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: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<system> \n\t<swRev>2.50-06-15</swRev>\n <hwRev>1.0</hwRev>\n \t<ident>SINA</ident>\n \t<class>class IC</class>\n \t<description>does something</description>\n </system>\n"
Wed Sep 28 15:36:06 2016 Debug: after waitForFinished( 6000 )
Wed Sep 28 15:36:06 2016 Debug: ICICIC
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 tried clean builds and running qmake (over and over) as well as reverting back to Qt 5.5.1 (VS2013) without any luck.
This used to work fine, I've no idea what might of changed. Any thoughts would be greatly appreciated.
Ian
Bookmarks