6

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?

4
  • The second argument in start-process is the output buffer's name, which can be nil to suppress the output buffer entirely. Is that what you are asking?
    – lawlist
    Oct 15, 2015 at 6:15
  • No, I still want to see stdout since I grab that time stamp at times. That all works great if it's just music, only the video produces the junk to stderr.
    – jtgd
    Oct 15, 2015 at 6:34
  • In that case, you can set up a filter to only print the strings or portions of strings that you want to see -- you'll need to identify either the stuff you want to see or the stuff you don't want to see and set up some rules -- e.g., with regexp and string= etc. gnu.org/software/emacs/manual/html_node/elisp/…
    – lawlist
    Oct 15, 2015 at 6:51
  • Thanks lawlist, I look forward to playing with filters. I might even try that for this project since it seems to make sense for what I'm doing.
    – jtgd
    Oct 16, 2015 at 6:51

2 Answers 2

4

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.

3
  • 1
    In 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
    – clemera
    Oct 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.
    – jtgd
    Oct 16, 2015 at 6:48
  • As for this being an emacs forum, your suggestion was perfectly apropos to the problem which involves command lines.
    – jtgd
    Oct 16, 2015 at 6:55
4

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.

2
  • 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
    – xeruf
    Nov 23, 2020 at 12:58
  • @Xerus Done. What kind of errors are you getting?
    – Basil
    Nov 23, 2020 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.