From mboxrd@z Thu Jan 1 00:00:00 1970 From: garjola@garjola.net Subject: org-babel: capturing the output of a shell command that does not return Date: Wed, 19 Sep 2018 22:34:22 +0200 Message-ID: <87h8ildy5t.fsf@pc-117-162.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2jBK-0007zY-H8 for emacs-orgmode@gnu.org; Wed, 19 Sep 2018 16:34:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g2jBH-0000JA-31 for emacs-orgmode@gnu.org; Wed, 19 Sep 2018 16:34:42 -0400 Received: from 10.mo3.mail-out.ovh.net ([87.98.165.232]:39412) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g2jBG-0008Vz-Pb for emacs-orgmode@gnu.org; Wed, 19 Sep 2018 16:34:38 -0400 Received: from player718.ha.ovh.net (unknown [10.109.160.76]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 4DD581D2492 for ; Wed, 19 Sep 2018 22:34:24 +0200 (CEST) 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" To: emacs-orgmode@gnu.org Hi, I need to capture the output of a shell command run from a babel code block, but this command does not return. By that, I mean that the command prints some text to the terminal, but does not end (it launches a deamon). Something like this: #+BEGIN_SRC bash jupyter kernel #+END_SRC When run in a terminal, the command outputs some text like: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > [KernelApp] Starting kernel 'python3' > > [KernelApp] Connection file: /run/user/1000/jupyter/kernel-8a5cf00c-182c-4212-9bbc-7aa6ec436b95.json > > [KernelApp] To connect a client: --existing kernel-8a5cf00c-182c-4212-9bbc-7aa6ec436b95.json > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > and sits there waiting for requests. I would like to capture the output to parse it. I need the name of the json file to pass it as a :session argument to subsequent code blocks like this: #+BEGIN_SRC emacs-lisp (setq org-babel-default-header-args (cons '(:session . "/run/user/1000/jupyter/kernel-8a5cf00c-182c-4212-9bbc-7aa6ec436b95.json") (assq-delete-all :session org-babel-default-header-args))) #+END_SRC #+BEGIN_SRC ipython :results output drawer :session "/run/user/1000/jupyter/kernel-8a5cf00c-182c-4212-9bbc-7aa6ec436b95.json" print(2+2) #+END_SRC Maybe there is another way to run the shell command and extract the file name I need (in elisp?), but I don't know how. I anybody could point me in the right direction, this would be very helpful. Thank you. G. --