From: garjola@garjola.net
To: emacs-orgmode@gnu.org
Subject: org-babel: capturing the output of a shell command that does not return
Date: Wed, 19 Sep 2018 22:34:22 +0200 [thread overview]
Message-ID: <87h8ildy5t.fsf@pc-117-162.i-did-not-set--mail-host-address--so-tickle-me> (raw)
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.
--
next reply other threads:[~2018-09-19 20:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 20:34 garjola [this message]
2018-10-04 15:09 ` org-babel: capturing the output of a shell command that does not return Grant Rettke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h8ildy5t.fsf@pc-117-162.i-did-not-set--mail-host-address--so-tickle-me \
--to=garjola@garjola.net \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).