Score:1

why "grep -v" or "tail -f" stop my program's output?

us flag

I have a server for Euro Truck Simulator 2 which is called by the following command:

LD_LIBRARY_PATH='$ORIGIN/../../linux64' eurotrucks2_server

When the server is running, sometimes I get these lines in console (and I'd like to hide them):

src/steamnetworkingsockets/clientlib/steamnetworkingsockets_sdr_common.h (564) : m_pServer->m_nReplyTimeoutsSinceLastRecv == 0

But whenever I append a | grep -v "Timeout" or | grep -v "steamnetworkingsockets", the server output is truncated at precisely this line:

Setting breakpad minidump AppID = 227300

I also tried the --line-buffered option for grep without luck and also removing grep and using | tail -f has the same result..

Here's the whole output: https://paste.debian.net/hidden/290d8573/

Thanks

Score:0
jp flag

The | only catches the standard output (stdout) stream; these messages are going to the standard error (stderr) stream. Using grep to hide the stderr messages is a XY problem.

Solution to the Y problem

To grep both at the same time you need to forward stderr stream to stdout with 2>&1, e.g.,

eurotrucks2_server 2>&1 | grep -v "Timeout"

Solutions to the X problem

  • Discard stderr output with 2>/dev/null, e.g.,

    eurotrucks2_server 2>/dev/null
    
  • Forward (append) stderr output to a log file with 2>>/path/to/error.log, e.g.,

    eurotrucks2_server 2>>/var/log/eurotrucks2_server_error.log
    
roughnecks avatar
us flag
I'm sorry but it still stops at the same point.
roughnecks avatar
us flag
this seems to work: 2> >(grep -v "Timeout"). Still waiting a bit to see if something (which shouldn't) shows up.
roughnecks avatar
us flag
yeah, not working still, I see all of the content which should be hidden.
I sit in a Tesla and translated this thread with Ai:

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.