Ask Your Question
0

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

asked 2018-11-23 14:47:00 +0000

Servante gravatar image

updated 2019-03-09 19:45:24 +0000

grahamb gravatar image

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.

edit retag flag offensive 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 gravatar imageGuy 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 gravatar imageGuy Harris ( 2018-11-23 18:47:05 +0000 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-11-23 18:31:41 +0000

Pascal Quantin gravatar image

Use tshark -D 1> file.txt

edit flag offensive delete link more

Comments

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

Guy Harris gravatar imageGuy Harris ( 2018-11-23 18:42:27 +0000 )edit

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

Servante gravatar imageServante ( 2018-11-23 18:46:21 +0000 )edit
0

answered 2018-11-23 18:47:57 +0000

Servante gravatar image

In my case helped this command :

sudo tshark -D | tee file.txt
edit flag offensive delete link more

Comments

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

Guy Harris gravatar imageGuy Harris ( 2018-11-23 19:18:24 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-11-23 14:47:00 +0000

Seen: 8,985 times

Last updated: Nov 23 '18