Score:1

How to stop tshark or tcpdump without `Unable to write output: Broken pipe` error?

us flag
Maf

I need to stop tcpdump or tshark loop based on a condition. Currently I'm using break.

while IFS= read -r line; do if [[ $line =~ 'some protocol' ]]; then echo $line; break; fi; done < <(sudo tcpdump)

or

while IFS= read -r line; do if [[ $line =~ 'some protocol' ]]; then echo $line; break; fi; done < <(sudo tshark)

How can I do that in a way I don't get the message Unable to write output: Broken pipe

David avatar
cn flag
Why do you not want to see the message when you do not know what the message means? If it was me I would be trying to understand the message not stop it.
Maf avatar
us flag
Maf
I really need both man. I know that's an issue because it's causing a timeout in some environments, but I could not find much about the meaning so far. All I know is that after the message the terminal still keeps busy with some process. I really tried to understand the message before I came here.
bac0n avatar
cn flag
think this summary at the end tries to write the pipe after it's closed. Could probably silence it with `tcpdump -l 2>/dev/null` or `unbuffer tcpdump -l`
Maf avatar
us flag
Maf
I understood now. Thanks!
Maf avatar
us flag
Maf
Could you please explain the options `-l 2>/dev/null`?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.