PDA

View Full Version : Errors using tshark in QProcess



Miss Engineer
17th October 2014, 06:51
Hello,
I am trying to display the rtt values from a wireshark pcap file. I am using QProcess as follows:

QString exec="C:/Progra~1/Wireshark/tshark.exe";
QStringList args;
args<< "-r" <<qPrintable(filepath)<<"-Y"<<"tcp.analysis.ack_rtt and tcp.stream eq 0"<<"-e"<<"\"tcp.analysis.ack_rtt\""<<"-T"<<"fields"<<"> C:/it/rtt.txt";
tshark->start(exec, args, QIODevice::ReadWrite);


However, I keep getting the following error using

qDebug()<<tshark->readAllStandardError();


tshark: Display filters were specified both with "-d" and with additional command-line arguments.


Please advise on what I may be doing wrong. Running from command line produces no errors and works just fine.

wysota
17th October 2014, 07:33
I think there is a number of problems with your code. First you should've quote the arguments yourself unless you want to reach the application quoted (and you probably don't). Second, you might want to split the filter argument into separate tokens unless wireshark expects to receive the filter as a single argument (you would have to quote it out escape the spaces when starting the command from cli). Third, redirection operator is interpreted by the shell and there is no shell here thus '>' will be passed to the application you are running and it probably won't understand it. You will have to intercept the output yourself and stream it to the destination file.

Miss Engineer
20th October 2014, 13:50
I think there is a number of problems with your code. First you should've quote the arguments yourself unless you want to reach the application quoted (and you probably don't). Second, you might want to split the filter argument into separate tokens unless wireshark expects to receive the filter as a single argument (you would have to quote it out escape the spaces when starting the command from cli). Third, redirection operator is interpreted by the shell and there is no shell here thus '>' will be passed to the application you are running and it probably won't understand it. You will have to intercept the output yourself and stream it to the destination file.
Thanks a lot.. this was very helpful