[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [babel] Parse another code block's output then use captured data
From: |
Eric Schulte |
Subject: |
Re: [O] [babel] Parse another code block's output then use captured data in another code block |
Date: |
Fri, 07 Mar 2014 08:35:30 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Would something like the following work?
Rehan Iftikhar <address@hidden> writes:
> Hello
>
> I have a .org file where I am using sh code blocks to interact with a REST
> API via curl.
#+name: downloader
#+begin_src sh
curl something
#+end_src
> My first call is to authenticate with the REST API which returns a
> token in the HTTP response. I would like to parse that HTTP response
> (ie. with elisp via a subsequent code block)
#+name: parser
#+begin_src emacs-lisp :var input=foo
;; do parsing
#+end_src
> and use the token in subsequent sh code blocks.
>
#+begin_src sh :var data=parser(downloader)
echo "$data"
#+end_src
>
> Right now I am doing this via a manual step where I step where I run
> the first sh code block, set a :var PROPERTY, and then run the rest of
> the sh code blocks. I would like to automate it if possible.
>
It is possible to chain code blocks in variable lines as shown, see the
manual pages on the :var and potentially also the :post header
arguments. Also, the following has multiple examples demonstrating this
sort of usage.
http://www.jstatsoft.org/v46/i03/
Best,
>
> Thanks,
> -Rehan
--
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D