THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

How can I write the output of tshark -D to a file?

I user this command from ssh console :

# tshark -D

and get correct result:

1. eth0 
2. nflog 
3. nfqueue 
4. usbmon1 
5. any 
6. lo (Loopback)

How can I save this output in file ? I tried this :

tshark -D > file.txt

but file.txt has been created empty. where is my error ?

UPD I also tried so :

tshark -D -w file.txt

but in this case file.txt even not been created.

Servante's avatar
5
Servante
asked 2018-11-23 14:47:00 +0000
grahamb's avatar
23.8k
grahamb
updated 2019-03-09 19:45:24 +0000
edit flag offensive 0 remove flag close merge delete

Comments

What does tshark --version print?

At least with Wireshark 2.6.5rc0-53-g80265eff, running on UN*X (macOS, but it should be the same on all UN*Xes, including Linux), tshark -D >/tmp/stdout puts the list of devices into /tmp/stdout. Perhaps you're running an older version and perhaps that version wrote the output of -D to the standard error.

Guy Harris's avatar Guy Harris (2018-11-23 18:44:47 +0000) edit

-w is only used when you're capturing traffic or reading a capture file and writing the packets in that file to another file; it does not work, for example, when you're listing interfaces with -D.

When capturing traffic, -w causes a binary packet capture, with raw packet data, to be written to the file; redirecting the standard output causes the text output of dissected packets to be written to the file, so -w isn't a replacement for redirecting the standard output.

Guy Harris's avatar Guy Harris (2018-11-23 18:47:05 +0000) edit
add a comment see more comments

2 Answers

0

In my case helped this command :

sudo tshark -D | tee file.txt
Servante's avatar
5
Servante
answered 2018-11-23 18:47:57 +0000
edit flag offensive 0 remove flag delete link

Comments

So what does sudo tshark -D >file.txt do?

Guy Harris's avatar Guy Harris (2018-11-23 19:18:24 +0000) edit
add a comment see more comments
0

Use tshark -D 1> file.txt

Pascal Quantin's avatar
5.8k
Pascal Quantin
answered 2018-11-23 18:31:41 +0000
edit flag offensive 0 remove flag delete link

Comments

1> file and >file are the same thing - they both redirect the standard output to file.

Guy Harris's avatar Guy Harris (2018-11-23 18:42:27 +0000) edit

used sudo tshark -D | tee file.txt . it's worked perfectly.

Servante's avatar Servante (2018-11-23 18:46:21 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer