Results 1 to 2 of 2

Thread: QProcess question

  1. #1
    Join Date
    May 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QProcess question

    Hi,

    I was trying out QProcess to send console commands and get what it returns. I tried to send a valid rsh command with an invalid address to see if QProcess returns me any error msg but it doesn't... not sure what i have done wrong. Below are the code i test with...modified from the qt qprocess example.

    Qt Code:
    1. #include <QProcess>
    2. #include <iostream>
    3. #include <QtCore>
    4.  
    5. using namespace std;
    6.  
    7. int main(){
    8.  
    9. QProcess *gzip = new QProcess(0);
    10. gzip->start("rsh -l usr 192.168.20.1 rcp /home/usr/0.txt usr2@192.168.20.2:/home/usr2/rsh/");
    11. if (!gzip->waitForStarted())
    12. return false;
    13.  
    14. gzip->closeWriteChannel();
    15.  
    16. if (!gzip->waitForFinished())
    17. return false;
    18.  
    19. QByteArray result = gzip->readAllStandardError();
    20. cout << QString(result).toStdString() << endl;
    21.  
    22. if(gzip) delete gzip;
    23. }
    To copy to clipboard, switch view to plain text mode 

    thanks

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QProcess question

    Its upto the program running to set the error appropriately. Have a look at exitCode in QProcess to get this error code.

  3. The following user says thank you to squidge for this useful post:

    hakermania (1st August 2011)

Similar Threads

  1. QProcess question
    By PH5 in forum Newbie
    Replies: 0
    Last Post: 4th February 2010, 23:43
  2. question on QProcess
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2009, 07:23
  3. QProcess question
    By lni in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2007, 19:06
  4. Question about QProcess
    By lni in forum Qt Programming
    Replies: 5
    Last Post: 27th April 2007, 23:08
  5. QProcess Question
    By Vash5556 in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2007, 16:24

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.