Results 1 to 3 of 3

Thread: Errors using tshark in QProcess

  1. #1
    Join Date
    Apr 2014
    Posts
    14
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default Errors using tshark in QProcess

    Hello,
    I am trying to display the rtt values from a wireshark pcap file. I am using QProcess as follows:
    Qt Code:
    1. QString exec="C:/Progra~1/Wireshark/tshark.exe";
    2. 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";
    3. tshark->start(exec, args, QIODevice::ReadWrite);
    To copy to clipboard, switch view to plain text mode 

    However, I keep getting the following error using
    Qt Code:
    1. qDebug()<<tshark->readAllStandardError();
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Errors using tshark in QProcess

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Miss Engineer (20th October 2014)

  4. #3
    Join Date
    Apr 2014
    Posts
    14
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Errors using tshark in QProcess

    Quote Originally Posted by wysota View Post
    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

Similar Threads

  1. QProcess crashes second QProcess
    By Ion in forum Newbie
    Replies: 1
    Last Post: 23rd September 2014, 22:00
  2. Replies: 1
    Last Post: 3rd June 2013, 14:11
  3. Replies: 0
    Last Post: 23rd March 2013, 20:23
  4. "Process failed to start: " and qprocess generic errors
    By scott_hollen in forum Qt Programming
    Replies: 8
    Last Post: 22nd November 2011, 16:03
  5. Replies: 0
    Last Post: 26th August 2010, 11:44

Tags for this Thread

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.