This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

starting capture from the command line with a display filter active

0

I have tried using the -R option but it seems it is only for reading previously captured files? Is there anyway of doing this please. I have just downloaded latest stable version 1.6.0 and rebuilt on centos 5.5.

e.g. wireshark -i bond0 -R tcp.port==8600 -k and whatever else options etc

I found a faq with someone offering a solution (which was admitted that it did not work) with hope someone would answer.

any ideas most greatful

asked 18 Jul '11, 07:36

spotthemaniac's gravatar image

spotthemaniac
11335
accept rate: 0%


One Answer:

0

To confirm, the man-page for wireshark suggests that -R is only for reading capture files.

-R {read (display) filter}

When reading a capture file specified with the -r flag, causes the specified filter (which uses the syntax of display filters, rather than that of capture filters) to be applied to all packets read from the capture file; packets not matching the filter are discarded.

EDIT: If you're building Wireshark, you might as well add code to allow setting the display filter for live captures. See funnel_set_filter and funnel_apply_filter for examples of how to set a display filter.

answered 18 Jul '11, 07:50

helloworld's gravatar image

helloworld
3.1k42041
accept rate: 28%

edited 18 Jul '11, 09:06

yes thanks i understand that, I need to run some repetitive tests and would like a one shell command to run wireshark and then look at the captures. Typing in the display filter every time justs adds nause and the possibility of error.

(18 Jul '11, 08:06) spotthemaniac

You can also save the Display Filters:
Wireshark User's Guide: 6.6. Defining and saving filters

Or you can edit the dfilters file:
C:\Documents and Settings\USER\Application Data\Wireshark
Add your filter to the file.
Make sure you end with an empty line, otherwise you won't see your filter.

"No ARP and no DNS" not arp and !(udp.port == 53)
"your filter" your filter
(18 Jul '11, 10:47) joke