emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel: capturing the output of a shell command that does not return
@ 2018-09-19 20:34 garjola
  2018-10-04 15:09 ` Grant Rettke
  0 siblings, 1 reply; 2+ messages in thread
From: garjola @ 2018-09-19 20:34 UTC (permalink / raw)
  To: emacs-orgmode

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.

-- 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-04 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-19 20:34 org-babel: capturing the output of a shell command that does not return garjola
2018-10-04 15:09 ` Grant Rettke

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).