reddit / emacs

Why does journalctl and org-babel tramp not work?

moogah · 2022-12-22 04:01
I've been trying to debug this for hours and at this point I'm about to throw my laptop out of a window. ​ I have consul installed on a host. If I ssh into that host and: sudo journalctl -u consul I'll get a bunch of log output. When I'm messing around with consul, the log output at startup is super helpful to capture, so I'd love to have this in an org document, captured with org-babel and tramp. seems easy, but here is what I get as output: #+BEGIN_SRC sh :async t :dir /ssh:moogah@hl1.local|sudo:: pwd whoami journalctl -u consul --no-tail --no-page echo "DONE" #+END_SRC #+RESULTS: if I skip the journalctl, this is what I get: #+BEGIN_SRC sh :async t :dir /ssh:moogah@hl1.local|sudo:: pwd whoami echo "DONE" #+END_SRC #+RESULTS: | /root | | root | | DONE | So.. what's the issue with journalctl??
kornaque · 2022-12-22 06:20
You can add `:session *Session*` to create a buffer `*Session*` where the commands are run. It will help for the debugging. Secondly, for a shell code block, you need to specify `:results output` so that the standard output of the code is printed in results. Now, supposing there is no connection issue with the remote, this should work. #+BEGIN_SRC sh :async t :dir /ssh:moogah@hl1.local|sudo:: :results output pwd whoami journalctl -u consul --no-tail --no-page echo "DONE" #+END_SRC A good reference: [https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-shell.html](https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-shell.html)