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(){
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;
cout <<
QString(result
).
toStdString() << endl;
if(gzip) delete gzip;
}
#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;
}
To copy to clipboard, switch view to plain text mode
thanks
Bookmarks