I'm using start-process
to run mplayer and when playing videos I get a ton of output to stderr from "vdp_...". On the command line I usually just 2>/dev/null but start-process
runs it directly without a shell. (I tried start-process-shell-command
but it simply does not work at all). call-process
lets you provide a list for separate stdout and stderr but it seems start-process
does not. I don't see an option to mplayer to inhibit the output. If only there were a way to do with start-process
what you can do with call-process
. Is there some way I'm not seeing to do this?
2 Answers
I know this is an emacs forum, but maybe the simplest thing to do is to write a simple shell script that filters stderr. For example in file nostderr.sh
:
#!/bin/sh
$@ 2>/dev/null
exit $?
And then run that in your start-process
.
-
1In fact this is what the docstring says as well:
If you want to separate standard output from standard error, invoke the command through a shell and redirect one of them using the shell syntax
– clemeraOct 15, 2015 at 23:29 -
Yes, that's one of the work-arounds I'd thought of, but good catch on finding that in the docstring. For that I'll give you the win. What I ended up doing was just searching further back and found what I wanted from the stdout. But in cases when what you are searching for cannot be separated from stderr, this is probably best.– jtgdOct 16, 2015 at 6:48
-
As for this being an emacs forum, your suggestion was perfectly apropos to the problem which involves command lines.– jtgdOct 16, 2015 at 6:55
Emacs 25 introduced the function make-process
for creating asynchronous processes, which is lower-level than start-process
. In particular, you can separate stderr
from stdout
by passing a buffer or pipe as the function's :stderr
keyword argument. For example:
(make-process :name "mplayer"
:buffer (generate-new-buffer "*mplayer out*")
:command '("mplayer" "/path/to/video")
:connection-type 'pipe
:stderr (generate-new-buffer "*mplayer err*"))
The standard output and error streams of mplayer
will now appear in buffers with names like *mplayer out*
and *mplayer err*
, respectively.
See (info "(elisp) Asynchronous Processes")
for more information.
-
I have tried to replace start-process with make-process but I keep getting errors and am unfortunately not well-versed in elisp... an example might be nice here– xerufNov 23, 2020 at 12:58
-
start-process
is the output buffer's name, which can benil
to suppress the output buffer entirely. Is that what you are asking?