Reputation: 143
I have an application that is using XVFB in order to run headless. The application runs fine, but I do get large amount of the elusive Xlib: extension "RANDR" missing on display ":1" error. The error really has no consequence, except that the large number of them fill our log file with useless info. What I'd like to do is filter outthat string.
We run generate the log file like so:
DISPLAY=":1" $PYBIN myScript.pyc > myLogfile.log 2>&1 &
I'm trying to pipe the output of the python script into sed, filter out 'Xlib: extension "RANDR" missing on display ":1"', and then write the results to myLogfile.log. This is what I'm trying, but no dice:
DISPLAY=":1" $PYBIN myScript.pyc | sed -n "missing on display" > myLogfile.log
Where do I redirect stderr to stdout so that they both are processed by sed? How do I correctly format the REGEX?
Thank you!
Upvotes: 1
Views: 2284
Reputation: 43401
Using sed
, you can use a pattern and the d
flag:
DISPLAY=":1" $PYBIN myScript.pyc 2>&1 \
| sed '/missing on display/d' \
| > myLogfile.log
I'm splitting the command on multiple line with \
.
Upvotes: 2
Reputation: 15917
If it's simply "missing on display" you want to filter out, you can use grep -v as such:
DISPLAY=":1" $PYBIN myScript.pyc &> | grep -v 'Xlib: extension "RANDR" missing on display ":1"' > myLogfile.log
The &>
redirects all output to STDOUT under bash/ksh. If you're running another shell, then you may want to use 2>&1
instead.
"2" is the file descriptor for STDERR, so we're saying "send the output of FILE #2 to the same address (&) as FILE #1" (STDOUT).
Upvotes: 1
Reputation: 33063
You can use grep
instead:
DISPLAY=":1" $PYBIN myScript.pyc 2>&1 | grep -v "missing on display" > myLogfile.log
Upvotes: 2