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

How to print a list of tshark interfaces to a txt file?

0

Looks simple but is annoying...

dumpcap.exe -D >> interfaces.txt

or:

tshark.exe -D >> interfaces.txt

Because interface numbers can be different among different machines, i want to use this command to sort out the Local Ethernet Cable connection and use it as a variable in my tshark script after sorting this out first... but i can't seem to print a list to a txt file?!

Thanks!

asked 08 Mar '12, 05:26

Marc's gravatar image

Marc
147101316
accept rate: 27%


One Answer:

3

Thats because the output of dumpcap -D isn't printed to stdout, but to stderr, and what you're trying to do is to redirect stdout to a file. So you need to redirect stderr instead.

Try this: dumpcap -D 2>interfaces.txt, where the "2>" stands for "please redirect stderr".

See this Microsoft Ressource for a detailed explanation of the redirecting of handles.

answered 08 Mar '12, 05:34

Jasper's gravatar image

Jasper ♦♦
23.8k551284
accept rate: 18%

edited 08 Mar '12, 05:36

Djeez! That was very fast ;-) Thanks Jasper!

(08 Mar '12, 05:40) Marc

Could i use this in 1 commandline? ie something like.. tshark.exe -D | grep therightinterface | tshark capturecommandline

(08 Mar '12, 05:50) Marc

Depends... you'll have to redirect stderr to stdout to be able to pipe it, e.g. like this: tshark -D 2>&1|grep therightinterface...

(08 Mar '12, 06:02) Jasper ♦♦