Results 1 to 3 of 3

Thread: App No Longer Works When Launched from Outside Creator

  1. #1
    Join Date
    Sep 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default App No Longer Works When Launched from Outside Creator

    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.

    Qt Code:
    1. void MainWindow::Perform1stSSHcmd()
    2. {
    3. QPalette palette;
    4. // hostname: THIS IS OUR 1st SSH COMMAND SO WE WANT TO DETERMINE IF THE KEYS ARE SET UP OK...
    5. QProcess* qp = new QProcess( this );
    6. QString userAndCommand = "root@";
    7. userAndCommand.append( m_cmsIp );
    8. userAndCommand.append(" hostname"); // cmd we want to execute on the remote server
    9.  
    10. qp->start( m_plinkPuttyCmd.arg( userAndCommand ));
    11. qp->waitForFinished( 16000 ); // I've tried vaious values for this
    12. QString output = qp->readAll();
    13. QString err = qp->readAllStandardError();
    14. // ... SNIP various error checking here ...
    15.  
    16. // Now the system info
    17. m_sysInfoProc = new QProcess(this);
    18.  
    19. qDebug() << "About to read systemInfo.xml... ";
    20. if( !connect( this->m_sysInfoProc, SIGNAL( readyReadStandardOutput() ), SLOT( readSystemInfoXML() ))) {
    21. qDebug() << "Connect Failed!!!!!";
    22. }
    23. userAndCommand = "root@";
    24. userAndCommand.append( m_cmsIp );
    25. qDebug() << "preparing cat of xml... ";
    26. userAndCommand.append(" cat /root/systemInfo.xml");
    27. m_sysInfoProc->start( m_plinkPuttyCmd.arg( userAndCommand ));
    28.  
    29. qDebug() << "->start issued... ";
    30. m_sysInfoProc->waitForFinished( 6000 );
    31. qDebug() << "after waitForFinished( 6000 )";
    32. }
    33.  
    34.  
    35. void MainWindow::readSystemInfoXML()
    36. {
    37. qDebug() << "In readSystemInfoXML()";
    38.  
    39. QProcess *systemInfoXml = qobject_cast<QProcess *>(sender());
    40. if( !systemInfoXml ) {
    41. return;
    42. }
    43.  
    44. QString res = systemInfoXml->readAllStandardOutput();
    45. qDebug() << "readSystemInfoXML() just read:" << res;
    46. if( !res.length() ) {
    47. return;
    48. }
    49. // . . . XML parsing of file contents . . . (not a concern, works fine)
    50. }
    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
    Last edited by anda_skoa; 29th September 2016 at 18:11. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: App No Longer Works When Launched from Outside Creator

    Aside from the usually bad idea to put the arguments of a command into the command string (better use command + list of arguments), this sounds like an environment issue.

    E.g. mabye something is present in the environment of QtCreator but not when run stand alone.

    I assume in both case you are running this with the same user account?

    Cheers,
    _

  3. #3
    Join Date
    Sep 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: App No Longer Works When Launched from Outside Creator

    Anda,

    Thanks for your reply and you are right, it was environment related. It turns out that I had an new IP which my ssh cache didn't know about. From the cmd line it was obvious, but from my Qt app, its qProcess was missing the correct string comparison for the 'do you want to cache this unknown key;. I thought that it would show up in the debug output, but I missed it.

    Thanks to Anda and everyone who read.

    Cheers,
    Ian

Similar Threads

  1. Replies: 4
    Last Post: 22nd April 2014, 16:34
  2. Replies: 2
    Last Post: 9th April 2014, 16:29
  3. Replies: 11
    Last Post: 5th July 2011, 12:11
  4. Replies: 0
    Last Post: 30th May 2011, 07:14
  5. Driver loaded only when launched from Creator
    By vieraci in forum Qt Tools
    Replies: 0
    Last Post: 16th September 2009, 03:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.