5

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?

  • 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 '15 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 '15 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 '15 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 '15 at 6:51
3

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.

  • 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 '15 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 '15 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 '15 at 6:55
3

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.

See the Emacs Lisp Manual node on Asynchronous Processes for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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