Would something like the following work?

Rehan Iftikhar <rehan.iftik...@gmail.com> 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

Reply via email to