PDA

View Full Version : QProcess question



jaxrpc
4th June 2010, 12:38
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.



#include <QProcess>
#include <iostream>
#include <QtCore>

using namespace std;

int main(){

QProcess *gzip = new QProcess(0);
gzip->start("rsh -l usr 192.168.20.1 rcp /home/usr/0.txt usr2@192.168.20.2:/home/usr2/rsh/");
if (!gzip->waitForStarted())
return false;

gzip->closeWriteChannel();

if (!gzip->waitForFinished())
return false;

QByteArray result = gzip->readAllStandardError();
cout << QString(result).toStdString() << endl;

if(gzip) delete gzip;
}

thanks

squidge
4th June 2010, 13:10
Its upto the program running to set the error appropriately. Have a look at exitCode in QProcess to get this error code.