PDA

View Full Version : How to invoke a executable that sends n/w request & gets xml response



rawfool
21st February 2014, 11:54
I have a executable that takes some arguments and sends n/w request and gets xml file/bytes as response. How do I execute this ?

On my CentOS, I execute it in terminal as

./myUtil --xml-output --password-file=myPassword --trf-downrate myUsername@my.serverName.com::home/
As a result, I get

<item trf_type="download" trf_rate="447.14kB/s"/>

How do I replicate the same from Qt program. Kindly help me with this.

Thanks.

anda_skoa
21st February 2014, 13:50
QProcess


Cheers,
_

rawfool
21st February 2014, 14:08
Yeah, I tried the same.
For this

./myUtil --xml-output --password-file=myPassword --trf-downrate myUsername@my.serverName.com::home/
I tried like this


void CWorker::startProcess()
{
QString idevsUtil = "./idevsutil";
QStringList args = "--xml-output" << "--password-file=myPasswrd" << "--trf-downrate" << "myUsernameUser1@gmail.com@irs345.server.com::home/";

mProcess->startDetached(idevsUtil, args); // mProcess is a member variable allocated in constructor
}


// In main
CWorker worker;
worker.startProcess();




But I got error saying -

error: invalid operands of types 'const char [13]' and 'const char [26]' to binary 'operator<<'

I'm unable to crack this.

Lesiok
21st February 2014, 14:43
Yours Qt have disabled QString::QString ( const QByteArray & ba ) constructor. Read more in QString doc.

stampede
21st February 2014, 16:35
There is no operator << for character arrays:

"--xml-output" << "--password-file=myPasswrd" << "--trf-downrate" << "myUsernameUser1@gmail.com@irs345.server.com::home/"
I think you meant

QStringList args;
args << "--xml-output" << "--password-file=myPasswrd" << "--trf-downrate" << "myUsernameUser1@gmail.com@irs345.server.com::home/";

anda_skoa
21st February 2014, 17:17
And just in case you have noticed by now: startDetached() is a static method.

Cheers,
_