From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [BABEL] Redirect stderr to stdout? Date: Fri, 02 Mar 2012 09:21:57 -0700 Message-ID: <87mx7znfbu.fsf@gmx.com> References: <20120302112909.GA25186@kenny.local> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:47795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3VFF-0000yC-5f for emacs-orgmode@gnu.org; Fri, 02 Mar 2012 11:22:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3VF9-0004aT-5z for emacs-orgmode@gnu.org; Fri, 02 Mar 2012 11:22:12 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:35944 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1S3VF8-0004aA-VZ for emacs-orgmode@gnu.org; Fri, 02 Mar 2012 11:22:07 -0500 In-Reply-To: <20120302112909.GA25186@kenny.local> (Viktor Rosenfeld's message of "Fri, 2 Mar 2012 12:29:09 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Viktor Rosenfeld writes: > Hi, > > is there a way to capture stderr output of a babel block and have it > appear in the results block (instead of being printed in the *Shell > Command Output* buffer)? On sh blocks I could redirect myself, but I'm > trying to capture the output of psql (the PostgreSQL client). > > Specifically, I have the following code block: > > #+BEGIN_SRC sql :noweb yes :results output verbatim > \timing on > <> > #+END_SRC > > #+RESULTS: > : count > : 95977 > > The \timing directive causes psql to print the runtime of the query on > stderr. If I run the query on the psql command line, the following > output appears: > > count > ------- > 95977 > (1 row) > > Time: 1895,558 ms > > I suppose that duplicating this output in Babel would be difficult, > because it interferes with the parsing of the result set. > Hi Viktor, Currently the only action Babel takes with STDERR is to display it in a pop-up buffer when code block evaluation fails. It would certainly be possible to add :results header argument to incorporate STDERR into results (and this desire has been expressed previously). Reasonable combination options would likely include (at least) the following. | stderr-only | return stderr instead of stdout | | 2>&1 | interleave stderr and stdout | | concat | add stderr to the end of stdout | | list | return a list of stderr and stdotu | The best (read simple and extensible) implementation and syntax for this behavior is not obvious to me (and I simply don't have time). If you (or anyone on the list) have any interest in hacking elisp code the place to start would be `org-babel-eval' for a serious implementation, or an quick hack may be possible through customization of the `org-babel-eval-error-notify' function. Hope this helps. Best, > > Cheers, > Viktor > -- Eric Schulte http://cs.unm.edu/~eschulte/