From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: Re: How to pass shell command result to :post source-block? Date: Sat, 19 Jan 2019 16:49:04 +0800 Message-ID: <87a7jx3udb.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> References: <87y37hcpq9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:40778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkmKo-0001Bt-Ps for emacs-orgmode@gnu.org; Sat, 19 Jan 2019 03:50:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkmKn-0002YO-KZ for emacs-orgmode@gnu.org; Sat, 19 Jan 2019 03:50:34 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:34171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkmKl-0002M2-7g for emacs-orgmode@gnu.org; Sat, 19 Jan 2019 03:50:33 -0500 Received: by mail-pl1-x62c.google.com with SMTP id w4so7418139plz.1 for ; Sat, 19 Jan 2019 00:50:27 -0800 (PST) In-Reply-To: <87y37hcpq9.fsf@gmail.com> 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: numbchild@gmail.com, Org Mode --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable See the code below: #+NAME: ansi-escape-filter #+begin_src emacs-lisp :var data=3D"" (with-temp-buffer (insert data) (ansi-color-apply-on-region (point-min) (point-max)) (buffer-string)) #+end_src #+RESULTS: ansi-escape-filter #+begin_src sh :dir /sudo:: :results output :post ansi-escape-filter(data= =3D*this*) tree /var/spool/postfix/ #+end_src `:results output` is needed to avoid parsing the shell output as a table. `data=3D*this*` is needed to pass the output to `ansi-escape-filter`. You can also check the example in the org info page for the :post header argument. Best, Ihor stardiviner writes: > I want to processing the shell ANSI escaping characters correctly or > just filter them out for display result correctly in Emacs. > > Here is my try: > > #+NAME: ansi-escape-filter > #+begin_src emacs-lisp > (ansi-color-apply-on-region (point-min) (point-max)) > #+end_src > > #+begin_src sh :dir /sudo:: :post ansi-escape-filter > sudo tree /var/spool/postfix/ > #+end_src > > #+RESULTS[<2019-01-19 10:58:39> f6d16244322abbd4fbe01bfaa084ac6bdd66a62c]: > : nil > > The second source block's result is supposed to be result of command > =3Dsudo tree /var/spool/postfix/=3D instead of =3Dnil=3D. > > Can someone help me how to do this correctly? > > --=20 > [ stardiviner ] > I try to make every word tell the meaning what I want to express. > > Blog: https://stardiviner.github.io/ > IRC(freenode): stardiviner, Matrix: stardiviner > GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 >=20=20=20=20=20=20=20 > --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEERZAHPFbUe3JemmzmZHB2Kn2hHYsFAlxC5IAACgkQZHB2Kn2h HYtawgf+Ijres/CuFy30pj0r5YfGhUQsoyMddJhAGsS+hwTCN2Z0pbsPLJJvwHmn hjyovnpAJ2PFky6bdQMTiVas1ZP4Xfy76BijoaekkAGBfc2qabvZOAaW3zuQqkY2 VEg5hyO38mwS7hDWlsmHPBT8Q/E5FICBbyjROglG+LXlCe99zJSJhuJqEQ1ENANe J1bLIPeiZN6FCI7nYs3c6FB3eT/O0zpGRwaIGau5OY+y5JNKhn2If8nTjKy/PXCJ CMP1OdjRY0SQI4RqV5Fmw55gqCis2kcdxCut60JL2B9eM8tsjHpB+YfaUcwRWfqJ fdlp4nfyia35GgnL5VzZCUqu/nd2gw== =ODpS -----END PGP SIGNATURE----- --=-=-=--